#include
int add(int);
void main()
{
int num,sum=0;
clrscr();
printf("How many no.s do u wanna add:");
scanf("%d",&num);
printf("\nEnter the no.s here:");
sum=add(num);
printf("The sum of the no.s is %d",sum);
getch();
}
int add(int x)
{
int n;
scanf("%d",&n);
if(x==0)
return(0);
else if(x==1)
return(n);
else
return(n+add(x-1));
}
No comments:
Post a Comment