Advertisement

Output : if u enter the limit 5. Then this will be added as 1+2+3+4+5.


#include<conio.h>
#include<stdio.h>

void main()
{   clrscr();
    int i,n,sum;
    printf("limit=");
    scanf("%d",&n);
    sum=0;
    i=1;
    while(i<=n)
    {  sum=sum+i;
       i++;
       }
       printf("%d",sum);
       getch();
       }

No comments:

Post a Comment

Please comment bellow. Share your knowledge