Computer Science, asked by preetinayak416, 4 months ago

algorithm and programming in c for sum of 100integers ​

Answers

Answered by peeyush321kumar
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 anindyaadhikari13
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:

  1. START.
  2. Create a loop that iterates 100 times.
  3. Ask the user for the number inside the loop.
  4. Add the integers and store them in sum variable.
  5. Display the sum.
  6. STOP.
Attachments:
Similar questions