//Data: 18 42 78 22 42 5 42 57
#include <iostream>
#include "unorderedArrayListType.h"
using namespace std;
int main()
{
unorderedArrayListType intList(25);
int number;
cout << "Enter 8 integers: ";
for (int count = 0; count < 8;
count++)
{
cin >> number;
intList.insertEnd(number);
}
cout << endl;
cout << "intList: ";
intList.print();
cout << endl;
cout << "The smallest number in
intList: "
<< intList.min() << endl;
system("pause");
return 0;
}
arrayListType.h
arrayListType.Imp.cpp
unorderedArrayListType.h
unorderedArrayListTypeImp.cpp
EXPLANATION : We first declare an abstract function in the class arrayListType. Since, min() being an abstract function we need to define it in the class unorderedArrayListType. You need to add the lines of code written by me in your cpp files and run it to check the min() function.
class arrayListType {
public:
int min(); //Declaring an abstract function in the class
arrayListType
}
#include <iostream>
#include <algorithm>
#include "unorderedArrayListType.h"
#include arrayListType.h
using namespace std;
class unorderedArrayListType : arrayListType {
public:
int unorderedArrayListType::min() //Defining the function min in
the class unorderedArrayListType
{
int* i1;
i1 = std::min_element(List+1, List+8); // Finding the
minimum value in the given list which consists of 8 elements.
return *i1; // Returning the minimum value in the
list.
}
int main()
{
unorderedArrayListType intList(25);
int number;
cout << "Enter 8 integers: ";
for (int count = 0; count < 8;
count++)
{
cin >> number;
intList.insertEnd(number);
}
cout << endl;
cout << "intList: ";
intList.print();
cout << endl;
cout << "The smallest number in
intList: "
<< intList.min() << endl;
system("pause");
return 0;
}
}
THANKS,
PLEASE UPVOTE THE ANSWER AS IT WOULD BE OF GREAT HELP TO ME.
Do not change anything in the supplied code below that will be the Ch12_Ex9.cpp except to...
C++ Programming Code Do not change anything in the supplied code below that will be the Ch16_Ex5_MainProgram.cpp except to add documentation and your name. Please use the file names listed below since your file will have the following components: Ch16_Ex5_MainProgram.cpp - given file //22 34 56 4 19 2 89 90 0 14 32 88 125 56 11 43 55 -999 #include <iostream> #include "unorderedLinkedList.h" using namespace std; int main() { unorderedLinkedList<int> list, subList; int num; cout << "Enter...
15.6: Fix the code to print the count from 1 to x (to loop x times) #include <iostream> // include the header file using namespace std; void count(int x){ for(int i=1; i<=x; i++){ cout<<x; } } int main(){ int x,i; cin >> x; count(x); return 0; } 15.7 Fix the nested for loops to print the count from 1 to x twice, e.g. "12....x12.....x" #include <iostream> // include the header file using namespace std; int main(){...
C++ Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original main(): int main() { double milesPerHour; double minutesTraveled; double hoursTraveled; double milesTraveled; cin >> milesPerHour; cin >> minutesTraveled; hoursTraveled = minutesTraveled / 60.0; milesTraveled = hoursTraveled * milesPerHour; cout << "Miles: " << milesTraveled << endl; return 0; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <iostream> using...
c++ by microsoft visual studio i wanna the answer for header file , cpp file , main file. 1). The function remove of the class arrayListType removes only the first occurrence of an element. Add the function removeAll to the class arrayListType that would remove all occurrences of a given element. Also, write the definition of the function removeAll and a program to test this function. 2)Add the function min to the class arrayListType to return the smallest element of...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
Write a c++ code into the given code to find composite numbers from the given random number list. The composite numbers is only counted once if there is a repeated number. I need to use this code and add on a code to find if the numbers generated is a composite function. Please help #include <cmath> #include <cstdlib> #include <ctime> #include <iostream> #include <vector> using namespace std; int main() { srand(time(NULL)); int size_of_list = 0; // the number of random...
How do I complete my code using an external file? External file: data.txt //the number 6 is in the external file Incomplete code: #include <iostream> #include <fstream> using namespace std; class example { int data[1]; public: example(); void read(ifstream &); }; example::example() { ifstream infile; infile.open("data.txt"); } void example::read(ifstream &infile) { infile >> data[1]; cout << data[1] << endl; } int main() { example example, read; //system("pause"); return 0;...
// Assignment11.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string> using namespace std; int main() { int size, m, n, c, d, first[10][10], second[10][10], sum[10][10]; cout << "Enter the number of rows and columns of matrices: "; cin >> size; m = size; n = size; cout << "Enter the elements of first matrix: "; for ( c = 0 ; c < m ; c++ ) for ( d = 0...
C++ Please complete the implementation of the following source code (Question3.cpp). You need to add your code in the source code where the comment “// your code” locates. After you finish the implementation, please also provide the output of your program. #include <iostream> using namespace std; class Shape { protected: // your code public: void setWidth (int w) { // your code } void setHeight (int h) { // your code } }; class Rectangle: public Shape { public: int...
C++ Language I have a class named movie which allows a movie object to take the name, movie and rating of a movie that the user inputs. Everything works fine but when the user enters a space in the movie's name, the next function that is called loops infinetly. I can't find the source of the problem. Down below are my .cpp and .h file for the program. #include <iostream> #include "movie.h" using namespace std; movie::movie() { movieName = "Not...