Sum up to given number.

A program for find the sum upto the number entered by the user:



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int y,t,sum=0;
printf("Enter the last value of the series, up to where the sum is required:  ");
scanf("%d",&t);
for(y=1;y<=t;y++)
{
 sum=sum+y;
}
printf("Sum of the series is: %f",sum);
getch();
getch();
}

Comments

Popular posts from this blog

Components of C language

Decision making using if statement

How to make payment for final certificate, migration, provisional for the students of last semester of ptu?