c program to find sum of n numbers using function and for loop
#c program find sum of n numbers using function for loop
Define the mathematical formula to calculate the sum of given number and print the sum of natural number
#include<stdio.h>
#include<conio.h>
void my_sum(int);
int main()
{
int n;
clrscr();
printf("please enter a number : ");
scanf("%d",&n);
my_sum(n);
getch();
return 0;
}
void my_sum(int n)
{
int i,s=0;
for(i=1;i<=n;i++)
{
s+=i;
}
printf("Sum of first %d integer is %d\n",n,s);
}