Introduction to function in C programming Language.

  Functions in C programming.
From the Given Diagram In this article, let have a brief introduction to functions in C Programming Language.
in Our daily lives we use calculator to perform basic mathematical calculations.
Calculator given is a electronic device that perform specific mathematical( Addition,Substraction,Multiplication,Division etc.) calculations,requires manual interaction for each operations.
when ever we perform some calculations using calculator there is a program running in the background.
We can say calculator is the program that perform some mathematical calculations.
as soon as when the user press a button on the calculator the program runs behind the calculator.
The program is the set of instruction and functions(code) that are used to perform some specific task.
From the fig. we can observe that the Calculator has the program running behind in it.
Let understand how the calculator works for mathematical calculations.
1. Addition + : + is the button on the calculator which is used to perform addition of a numbers entered by the user.
when user press the + button the function code Add() in the program associated on the button + get executed or called.The Function Add() performs the addition of numbers entered by the user and gives the addition result.
2. Substraction - : - is also the button on the calculator which is used to perform substraction of a numbers entered by the user.
when user press the - button the function code subtract() in the program associated on the button - get executed or called.The Function subtract() performs the substraction of numbers entered by the user and gives the result.
Simmilarly other operations works for the calculator.
Note: when the user press any button on the calculator the function code(program)associated on the button get called or execute.
the function code get called repeteadly when the user press the button or call the function.


Here is the simple code to understad functions in C programming.

#include <stdio.h>
int Add(int x, int y ) /* function declaration and ddefinition */
{
return x + y;
}
int main()
{
int x,y;
printf("\n Enter any two Numbers\n");
scanf("%d%d",&x,&y);
int result = Add(x, y);
printf("\nThe result %d+%d=%d", x,y,result);
return 0;
}


Previous Topic:-->> Array Assignments in C || Next topic:-->>Need for User Defined Function.
Other Topics: