Sunday, 29 July 2018

Program to find maximum of three number using user define function in C

A function can be define by the user as per the requirement of the user or programmer . To implement
a user define function , a programmer must contain the following three statement .

1. Function declaration or function prototype 

2. Function call statement

3. Function definition

Program of find maximum of three number using user define function in C

#include <stdio.h>
int max ( int , int , int ) ;                                                                                                                      void main () ;
{
int a , b , c ;
clrscr () ;
printf ("\n Enter value of a:") ;
scanf ("%d", &a) ;
printf ("\n Enter value of b:") ;
scanf ("%d", &b) ;
printf ("\n Enter value of c:") ;
scanf ("%d", &c) ;
d = max ( a,b,c ) ;
printf ("\n maximum number is %d",d) ;
getch () ;
}
int max ( int a , int b , int c ) 
{
if ( (a>b) && (a>c) )
return a ;
else if ( (b>a) && (b>c) )
return b ;
else
return c ;
}

This is program for finding maximum of three number in C using user define function. Here first of all we have to input three number from the user and write function call statement and print the value of maximum and outside the main function the function definition is written where the execution of program is takes place and output goes again to the function call statement where it is print on the output screen.



No comments:

Post a Comment

Featured post

Program to find maximum of three number using user define function in C++

A function can be define by the user as per the requirement of the user or programmer . To implement a user define function , a programmer ...