Functions
Functions
Suppose, you need to create a program to create a circle and color it. You can
create two functions to solve this problem:
Dividing a complex problem into smaller chunks makes our program easy to
understand and reuse.
The printf() is a standard library function to send formatted output to the screen.
This function is defined in the stdio.h header file. Hence, to use
the printf()function, we need to include the stdio.h header file using #include
<stdio.h>.
The sqrt() function calculates the square root of a number. The function is defined
in the math.h header file.
User-defined function
You can also create functions as per your need. Such functions created by the user
are known as user-defined functions.
#include<conio.h>
void main( )
printf(“Hello I am a function”);
}
#include<stdio.h>
#include<conio.h>
int addition(int,int);
void main()
int num1,num2,sum;
scanf("%d%d",&num1,&num2);
sum = addition(num1,num2);
getch();
int add;
add = x + y;
return(add);
main();
addition(x,y);