Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

where can i have a "cout" to get an output

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

(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 {}).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading