Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why this program is not running what the problem with the code i need help

0 votes
asked May 17, 2018 by Mahmud Muhammad (230 points)
#include <iostream>

using namespace std;

int main ()

{

int num = 0;

int sum=0;

cout << "Enter a number ";

cin >> num;

while(num<0)

cout<<"please enter a positive integer";

cin>>num;

}

for(int i = 1; i<=num; i++)

{

sum+=i;

}

cout<<"the total sum is"<<sum<<endl;

}

return 0;

1 Answer

0 votes
answered May 18, 2018 by LEANDRO CARVALHO MAIA DA SILVA (140 points)
#include <iostream>

using namespace std;

int main ()

{

int num = 0;

int sum=0;

cout << "Enter a number ";

cin >> num;

while(num<0){

cout<<"please enter a positive integer";

cin>>num;

}

for(int i = 1; i<=num; i++)

{

sum+=i;

}

cout<<"the total sum is"<<sum<<endl;

return 0;

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...