Program to find find sum of all number from 1 to N

#include<conio.h>

#include<stdio.h>

void main()

{

int a,n,sum;

clrscr();

printf("enter the value of N");

scanf("%d",&n);

a=n*(n+1);

sum=a/2;

printf("sum of all the number from 1 to N is=%d",sum);

getch();

}

Output

enter the value of N=10

sum of all the number from 1 to 10 is=55

enter the value of number from 1 to 20 is=210

Comments

Popular posts from this blog

Gove confirms mandatory housebuilding targets for councils will be abolished in face of Tory rebellion – UK politics live

Kotak Mahindra Bank Recruitment 2022 Released for Graduate Candidates And Apply Online