Answer to Question #45441 in C++ for paolo david

Question #45441
Write a program that asks the user to type 10 integers and write the number of occurrence
of the biggest value
do while program,.
c++
1
Expert's answer
2014-09-03T08:30:41-0400
#include <iostream>
int main() {
int *array = new int[10];
int max, i = 0, count = 0;
std::cout << "Input 10 integers" << std::endl;
do{
std::cin >> array[i];
i += 1;
} while (i < 10);
max = *array;
i = 0;
do{
if (array[i] > max) {
max = array[i];
}
i += 1;
} while (i < 10);
i = 0;
do{
if (array[i] == max) {
count += 1;
}
i += 1;
} while (i < 10);
std::cout << "Max value is " << max << ". You can see it " << count << " times in the array" << std::endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS