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();
}
#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