+ 1

Good evening how can find the greatest number between 5 number by using loop?

I need know how can solution?

25th Mar 2017, 3:44 PM
Bts...
Bts... - avatar
5 Respostas
+ 1
but he want any 5 number
25th Mar 2017, 4:31 PM
Bts...
Bts... - avatar
0
I don't understand this
25th Mar 2017, 4:26 PM
Bts...
Bts... - avatar
0
int numbers = {1, 3, 5, 7, 2}; int greatest = numbers[0]; for(int counter = 0; counter < 5; counter++) { if(numbers[counter] > greatest) greatest = numbers[counter]; } Also, you can replace the if statement by: greatest = (numbers[counter] > greatest) ? numbers[counter] : greatest;
25th Mar 2017, 4:28 PM
reddylopes
reddylopes - avatar
0
#include <iostream> using namespace std; void main() { int counter = 0; int number = 0; int largest = 0; cout << "Please enter up to 10 numbers and I will print the largest one on the screen.\n\n"; while (counter <= 10) { cout << "Number: "; cin >> number; counter++; if (number > largest) { largest = number; } else if (counter == 10) { cout << "The largest number was: " << number; break; } } }
25th Mar 2017, 4:28 PM
Saad Mohammed
Saad Mohammed - avatar
0
#include <iostream> using namespace std; int main(){ int i,n,big= 0; for (c=1;c <=5;c++){ cout << "Enter a number: "; cin >>n; if (n > big){ big= n; } } cout << "The biggest number is " << big; break; }
25th Mar 2017, 5:10 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar