May 14, 2023
program to use sum control statements in c language
#include<stdio.h>
int main()
{
int num,sum=0;
do
{
printf("Enter a number (enter 0 to stop) : ");
scanf("%d",&num);
sum+=num;
} while (num!=0);
printf("sum is %d\n",sum);
return 0;
}
output
Enter a number (enter 0 to stop) : 1
Enter a number (enter 0 to stop) : 4
Enter a number (enter 0 to stop) : 5
Enter a number (enter 0 to stop) : 7
Enter a number (enter 0 to stop) : 8
Enter a number (enter 0 to stop) : 0
sum is 25
by : Ajaj Khan
Quick Summary:
program to use sum control statements in c language copy #include<stdio.h> int main() { int num,sum=0; do { printf(“Enter a number (enter 0 to stop) : “); scanf(“%d”,&num); sum+=num; } while (num!=0); printf(“sum is %d\n”,sum); return 0; } output Enter a number (enter 0 to stop) : 1 Enter a number (enter 0 to stop) […]