C program to find the sum of n integer numbers using the function

Write a c program to find the sum of the N integer numbers using the fuctions.

#include <stdio.h>
#include <conio.h>

int sum (int number);

void main()
{
int n;

printf("How many number : ");
scanf("%d", &n);

printf("sum the %d numbers is : %d ",n,sum(n));
getch();
}
int sum(int number){

int i, add=0;

for(i=1; i<=number; i++){
add+=i;
}
return add;
}

Output

C program to find the sum of n integer numbers using function

TutsMaster.org

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.