0

Help me please, how can I make C++ program first natural numbers?

#include <iostream> using namespace std; int main() { int i, = 0; for(i=1;i<=10;i++) sum= 0,sum+i; if(i<10) cout <<i<<" + "; return 0; }

26th Jan 2021, 11:26 AM
Hyacenth Luyas
Hyacenth Luyas - avatar
5 odpowiedzi
+ 4
1. You have to declare variables first before using (try to find out what variable that is). 2. If you want to have multiple statement inside a loop, use curly brackets { }.
26th Jan 2021, 11:32 AM
noteve
noteve - avatar
+ 3
NOTE : Inside loop, when your loop is running the value of sum is being 0 , please see there are some syntax error also. Try again, Don't give up! All the best!
26th Jan 2021, 11:36 AM
Abhiyantā
Abhiyantā - avatar
+ 2
I spent about 3 mins reading your code and see what's happening and was gonna point the errors but other people already pointed it out, sooo i guess this is what you wanna print out? https://code.sololearn.com/cD5uZf1JSG0Z/?ref=app
26th Jan 2021, 11:37 AM
Rellot's screwdriver
Rellot's screwdriver - avatar
+ 1
Ah okay, thank you.
26th Jan 2021, 11:35 AM
Hyacenth Luyas
Hyacenth Luyas - avatar
26th Jan 2021, 11:59 AM
Hyacenth Luyas
Hyacenth Luyas - avatar