+ 3
How do you this in code? Exercise 2: I will give you a number n. S = 1+2+3+...+n . Then print S
I'm a beginner and barely learning anything. My teacher is already giving me hard questions. lol. But sometimes I don't know what he is talking about and it confuses me. Thank you all for responding. Namaste
4 Antworten
+ 19
#include <stdio.h>
int main() {
int a,b=1;
scanf("%d",&a);
start:
printf("%d",b);
if(--a>b)
{
b+=a;
goto start;
}
return 0;
}
+ 4
I just wrote this code for someone else about two hours ago:
https://code.sololearn.com/csfXuMdCM4AU/?ref=app
0
i have written a code for you
based on recursion
https://code.sololearn.com/csaGm8t5IkY5/?ref=app
0
main()
{int n,i;
scanf("%d",&n);
for (i=0;i<n;i++);
printf("sum=%d",i);
}