+ 4

How do you nest loops in C++

I've tried this method over and over but it keeps giving me errors: https://code.sololearn.com/ccp91I1Mj5Pp/#cpp I don't think it's featured in the course either. Help!

12th Jun 2017, 10:58 AM
Seyram Agudu
Seyram Agudu - avatar
4 odpowiedzi
+ 2
#include <iostream> using namespace std; int main() { int apt = 0; int ski = 0; int comp = 0; int count = 0; while (count<=700) { cin >> apt >> ski >> comp; int sum = apt+ski+comp; if (sum>=80) { cout << "You have been nominated for selection of CEO." << endl; } else { cout << "You have not been nominated for selection of CEO." << endl; //count += 1; take this statement of the else block } count += 1; } return 0; }
12th Jun 2017, 11:28 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
+ 2
OR Instead of while loop, use for loop //while (count<=700) { for (count = 0; count<=700;count++){ cin >> apt >> ski >> comp; int sum = apt+ski+comp; if (sum>=80) { cout << "You have been nominated for selection of CEO." << endl; } else { cout << "You have not been nominated for selection of CEO." << endl; } }
12th Jun 2017, 11:30 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
0
a loop in another loop means same as loop you make 2D matrix by c++ coding you can see loop in loop
12th Jun 2017, 4:37 PM
r j
0
Thank you so much!
19th Jun 2017, 10:59 AM
Seyram Agudu
Seyram Agudu - avatar