+ 2
Hi. What is wrong with this code
I am trying to sum the inputs from the users 5 times , here is the code #include <iostream> using namespace std; int main() { int num = 1; int total = 0; int number; while (num <= 5){ cin >> number; number += num; num++; cout << number } return 0; }
3 Answers
+ 1
#include <iostream>
using namespace std;
int main()
{
int x,sum=0,i;
for(i=1;i<=5;i++)
{
cin>>x;
sum = sum+x;
}
cout<< sum <<endl;
return 0;
}



