Need help about c++ mga ka phc.
ayaw mag stop ng program
Sa expression na
while ( n > 0) ;
Example.) n = -90
90 < 0; ( false )
Given problem:
Write a program written in c++ language to calculate the average of an unknown number of grade .
*Prompts the user to enter a grade each time through the loop.
* update the sum and number of grade.
*prompts the user to enter a negative grade after the last valid grade.
*continue looping while the input grade is not negative.
Kaso ayaw mag stop ng program kahit mag enter ako ng negative grade .
#include<iostream>
using namespace std;
int main () {
int i, n, b, t, sum = 0, num[100];
float ave;
for ( i = 0; ; i ++) {
cout<<i+1<<".Enter a Grade : ";
cin >> num;
t++;
sum += num;
ave = sum /t;
b=ave;
cout << " Sum : " << sum << endl;
cout << " ENTER NEGATIVE GRADE : ";
cin >> num;
}while ( n > 0 );
b=ave;
cout << " Average : " << b<< " % " <<endl;
return 0;
}
ayaw mag stop ng program
Sa expression na
while ( n > 0) ;
Example.) n = -90
90 < 0; ( false )
Given problem:
Write a program written in c++ language to calculate the average of an unknown number of grade .
*Prompts the user to enter a grade each time through the loop.
* update the sum and number of grade.
*prompts the user to enter a negative grade after the last valid grade.
*continue looping while the input grade is not negative.
Kaso ayaw mag stop ng program kahit mag enter ako ng negative grade .
#include<iostream>
using namespace std;
int main () {
int i, n, b, t, sum = 0, num[100];
float ave;
for ( i = 0; ; i ++) {
cout<<i+1<<".Enter a Grade : ";
cin >> num;
t++;
sum += num;
ave = sum /t;
b=ave;
cout << " Sum : " << sum << endl;
cout << " ENTER NEGATIVE GRADE : ";
cin >> num;
}while ( n > 0 );
b=ave;
cout << " Average : " << b<< " % " <<endl;
return 0;
}