answersLogoWhite

0

void main ()

{

int no1, sum, n;

clrscr()

sum = 0;

n = 1;

printf("\n enter the number to which sum is to be generated");

scanf("%d",&no1);

while(n<=no1)

{

sum=sum+n;

n=n+1

}

printf("\n the sum of %d = %d, no1, sum");

getch ();

}

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
RossRoss
Every question is just a happy little opportunity.
Chat with Ross
More answers

#include<stdio.h>

#include<conio.h>

int sum(int);

void main()

{

int n,s;

clrscr();

printf("Enter a number\n");

scanf("%d",&n);

s=sum(n);

printf("The sum of %d integer numbers=%d",n,s);

getch();

}

int sum(int n)

{

if(n<=0)

return 0;

else

return (n+sum(n-1));

}

User Avatar

Wiki User

11y ago
User Avatar

Add your answer:

Earn +20 pts
Q: C program to find sum of 'n' number using function?
Write your answer...
Submit
Still have questions?
magnify glass
imp