/*find the sum of series 1+2+3+... using formula */
#include<stdio.h>
#include<conio.h>
void main()
{
int num,sum=0;
clrscr();
printf("Enter index of series from like (1 to 10)");
scanf("%d",&num);
sum=num*(num+1)/2;
printf("sum of series %d",sum);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int num,sum=0;
clrscr();
printf("Enter index of series from like (1 to 10)");
scanf("%d",&num);
sum=num*(num+1)/2;
printf("sum of series %d",sum);
getch();
}
No comments:
Post a Comment