Addition of 1 to n numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,sum=0,n;
clrscr();
printf("enter the value");
scanf("%d",&n);
while(i<=n)
{
sum=sum+i;
i++;
}
printf("addition=%d",sum);
getch();
}
/*
output :-
----------
enter the value10
addition=55
*/
#include<conio.h>
void main()
{
int i=1,sum=0,n;
clrscr();
printf("enter the value");
scanf("%d",&n);
while(i<=n)
{
sum=sum+i;
i++;
}
printf("addition=%d",sum);
getch();
}
/*
output :-
----------
enter the value10
addition=55
*/
Comments
Post a Comment