You are on page 1of 7

SUMMATION OF A SET OF NUMBERS

PROGRAM:-
// header files
#include<stdio.h>
#include<conio.h>
Void main()
{

//variable declaration
int i,n,sum=0;

//prompt user
printf(“Enter the number”);
scanf(“%d”,&n);
for(i=1; i<=n; i++)
{
sum=sum+i;
}
printf(“summation is %d”,sum);
getch();
}

OUTPUT:-
ALGORITHM:-
1. Start
2. Declare input and output variables n,I,sum=0;
3. Prompt user to enter a number
4. Condition for loop
for(i=1; i<=n; i++)
{
sum=sum+i;
}
5. Display output(print sum)
6. End
Start

Int i,n,sum=0;

Read n

i=1

i<=n Print sum


A-1

Sum=sum+i

i=i+1

End

You might also like