For Loop Assignment.
For Loop Assignment.
For Loop Assignment.
WHILE(SUM PROGRAM)
#include <stdio.h>
int main() {
double number, sum = 0;
// the body of the loop is executed at least once
do {
printf("Enter a number: ");
scanf("%lf", &number);
sum += number;
}
while(number != 0.0);
printf("Sum = %.2lf",sum);
return 0;
}
WHILE(SUM PROGRAM)
#include<stdio.h>
main()
{ int i,n,sum=0;
printf("ENTER THE VALUE OF i=");
scanf("%d",&i);
printf("ENTER THE VALUE OF n=");
scanf("%d",&n);
while(i<=n)
{
sum=sum+i;
i++;
}
printf("sum=%d",sum);
return 0;
}