A function is a module or block of program code which deals with a particular task.
function will make code
reusable
it stop be mixing on coding
It avoid repeating parts of the programming coding
let make our add_integer to function and run it.
here is modified code, Blue color text show the changes we did to our previous code.
#include<stdio.h> // standard input output header file
#include<conio.h>
main()
{
int a,b;
printf("enter any number");
scanf("%d",&a); // or cin >> a
printf("enter any number");
scanf("%d",&b);
Add_Two_Integers(a,b);
Add_Two_Integers(12,23);
getch();
}
Add_Two_Integers(a,b) /* Add a and b */
int a,b;
{ int c;
c = a + b;
printf ("\n%d",c);
}
here it is in running
Add a comment