the code is OK and works I think but I don’t get the result that I’m looking for
`
#include <iostream>
using namespace std;
int main()
{
int sum;
int x;
sum =0;
x=1;
while(x<=100)
sum = sum+x ;
x = x+1 ;
}
`
so if I add a cout inside the int main it’s like they are not even there also if I have the
cout outside of the int main I will have a bug.
(plus the cout is going to be the answer which is 5050 but I don’t know where can I have the cout )
>Solution :
You put the cout inside the main function. To know what you did wrong when you tried that you are going to have to show us the code you wrote. Saying precisely what you mean by ‘it’s like they are not even there’ will help as well.
And as stated in the comments above your while loop is incorrect (missing {}).