algorithm and programming in c for sum of 100integers
Answers
Answered by
1
Answer:
Explanation:
int sum=0,i
for(i=1,i<=100;i++)
{
sum=sum+i;
}
printf ("Sum of first 100 intergers = %d\n", sum);
Answered by
0
Required Answer:-
Question:
- Write a C program to find sum of 100 integers.
Solution:
Here comes the program.
#include <stdio.h>
void main() {
int i,x, s=0;
for(i=1;i<=10;i++) {
printf("Enter a number: ");
scanf("%d", &x);
s+=x;
}
printf("Sum: %d", s);
}
Algorithm:
- START.
- Create a loop that iterates 100 times.
- Ask the user for the number inside the loop.
- Add the integers and store them in sum variable.
- Display the sum.
- STOP.
Attachments:
Similar questions