C PRACTICAL / ADD FIRST N NUMBER BY USING FUNCTION

hello friends....



TAKE THE FIRST STEP TO KNOWLEDGE FRIENDS BECAUSE KNOWLEDGE IS FREE. 


>> /* WRITE A FUNCTION PROGRAM TO ADD FIRST N NUMBER */

#include<stdio.h>
#include<conio.h>
int addition();

void main()
{
  int n,ans;
  clrscr();
  printf("enter store number : \n");
  scanf("%d",&n);
  printf("enter any %d number\n",n);
  ans=addition(n);
  printf("final ans is : %d\n",ans);
  getch();
}
int addition(x)
{
  int sum=0,i,value;
  for(i=0; i<x; i++){
    scanf("%d",&value);
    sum = sum + value;
  }
  return sum;
}

       /*  OUTPUT  */
============================

enter store number : 
5
enter any 5 number
1
2
3
4
5
final ans is : 15

* * * * * * * * * * * * * *
http://www.dnpdeveloper.com

if you have like this blog so share and subscribe, comment for this blog.
if your any question, so comment pleass.
MY INSTAGRAM ID : dnp176

Comments