//Write a program to print 1 to 50 term of natural number & sum by using while loop #include<stdio.h> #include<conio.h> void main() { int x=1,sum=0; clrscr(); while(x<=50) //While loop run if the condition remains true { printf("%d",x); sum = sum + x; x=x+1; } printf("Sum = %d",sum); //Sum is printed at the last getch(); }
Comments
Post a Comment