0
Help with C program for sum of two numbers in range
Hello, I have for homework to write program in C. User have to type two numbers and program will do sum of numbers in range (example: If user type 3 and 5 program will shows result of 3+4+5) using dowhile loop, but it no works. When I type 3 and 5 nothing no happens. Can you help me please? #include <stdio.h> #include <stdlib.h> int main() { int m,n,i,s=0; printf("Type two numbers\n"); scanf("%d%d",&m,&n); do { s=s+i; i++; } while(i<=n); if (i>0); printf("S=%d",s); return 0; }
2 Respostas
+ 4
Zoran Dori Do like this
do {
s = s + m;
m++;
}
while(m <= n);
+ 1
Works, thank you AJ #Level 20 End Day