Starting Vocational Training From 1-May-2024 Get Detail
Write a program in C to show the simple structure of a function to add given two numbers.
#include <stdio.h>
int sum (int, int);//function declaration
int main (void)
{
int total;
printf("
Function : a simple structure of function :
");
printf("------------------------------------------------
");
total = sum (5, 6);//function call
printf ("The total is : %d
", total);
return 0;
}
int sum (int a, int b) //function definition
{
int s;
s=a+b;
return s; //function returning a value
}