Thursday, September 20, 2012

program for sum of elements up to a limit

 program for sum of elements up to a limit
#include<conio.h>
#include<stdio.h>
void main()
{
int n,s=0;
clrscr();
for(i=1;;i++)                
{
printf("Enter the number\n");
scanf("%d",&n);
if(n>0)
s=s+n;
if(n==0)
break;
}                                        
printf("the sum is\n");
scanf("%d",s);
getch();
}

No comments:

Post a Comment