answersLogoWhite

0


Best Answer

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
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

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

}

This answer is:
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
Related questions

Which math function is used to find the square root of a number using java?

Math.sqrt(number) function is used to find the square root of a number.. try it


How do you write a c program to find area of rectangle using function?

There will be a function in it like this: double RectangleArea (double a, double b) { return a*b; }


How do you find by program a given number is integer or float?

If it contains a decimal point or an exponential part, then it should be handled as a float (or double).You can determine an existing variable's type in C using the type() function


Help I am using open office for PC and you cant find any function that will search the spreadsheet for a a number you put into a cell Is there a function for that?

It will find a number - if the number is not a formula. For example - if you search for the number 30 it will find it - BUT - if the product in a cell is the result of a formula it will disregard it.


Write a C program called MonthDays to find the number of days in a given month Test your code with different input values to demonstrate that your function is robust?

Write a C program called MonthDays to find the number of days in a given month Test your code with different input values to demonstrate that your function is robust?


Program to find biggest number among two numbers using template function?

template&lt;class T&gt; T&amp; max(const T&amp; x, const T&amp;y){return(x&gt;y?x:y); }


How do you find the value of a number in a function?

The number of function is Geometry


Can somebody give me the program to find simple interest using friend function in c plus plus?

Here is an example program: class obj{ public: float p,n,r,si; friend void calc( obj temp); }; void calc( obj temp){ si = (p*n*r)/100; } The initialization and function calling is essential.


How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


Are there any agent function that cannot be implemented by any agent program?

Yes there are agent functions that can not be implemented e.g. an agent can not find the largest prime number.


Write a program to find the factorial number using function?

//C program to find the factorial of a given number using functions #include&lt;stdio.h&gt; #include&lt;conio.h&gt; int fact(int); void main() { int f,t; clrscr(); printf("\nEnter any number:"); scanf("%d",&amp;f); t=fact(f); printf("1=%d",t); getch(); } int fact(int fa) { int i,fac=1,t; for(i=fa;i&gt;=2;i--) { // TO print the series printf("%dx",i); fac=i*fac; } return fac; }


Write a Program in c language to find the LCM without using functions?

You're supposed to do your homework yourself. (Mind you, you have to hav at least one function called main.)