im pretty new programming made lots of mistakes helllpppp
im writing program user should enter number of integers , program should print out how many numbers there in integers , there sum
#include <iostream> using namespace std; int main() { int n=3; int counteven; int count=1; int sum=0; cout<<"enter number of integers: "; cin>>n; while(count<=n) cin>>n; count++; if (n%2==0); { counteven; sum=sum+n; cout<<"the numbers are:"<<counteven<<endl; cout<<"the sum of eve numbers is:"<<sum<<endl;} system("pause"); return 0; }
thankss
it looks don't have braces ({}) while loop causing loop on line:
while(count<=n)
an example of correct while loop (taken here):
// custom countdown using while #include <iostream> using namespace std; int main () { int n = 10; while (n>0) { cout << n << ", "; --n; } cout << "liftoff!\n"; }
Comments
Post a Comment