How to add two number using function in c language.
first include header files .
This program is simple program in c language which is showing use of function to create in c program and call that function for adding two numbers .in simple method we can do also but , by using function it makes easier .
#include<stdio.h> // header files
void main() //start of main
{ //opening of main
int first_number,second_number; //declaration of two variable later which will store the values
clrscr();
printf("\n Enter 2 Number:"); //asking for enter the numbers
scanf("%d %d",&first_number,&second_number); //taking two numbers and storing into variable first_number and second_number.
printf("\Addition=%d",add(first_number,second_number)); calling function add()
} //closing of main
int add(int x,int y) //function add
{
return(x+y); //will give addition of two numbers
} // close function
0 comments: