Rita is very happy about the successful completion of pattern game by her students. By that time, Disneyland project manager announced a Mini project related to mathematical calculations. Rita thought of taking up that Mini project and completing it with the help of her students. She took that project, and then she splits the project into separate modules and hands it over to each student. The first module is to find maximum among three numbers.
Rita instructed students to follow the function specification strictly. Rita allotted this function to Patrick.
Help Patrick to write a C program to find the maximum of 3 numbers using functions.
Function Specification:
int findmaximum(int, int, int )
Input Format:
Input consists of 3 integers.
Output Format:
Refer sample input and output for formatting details.
Sample Input:
13
45
23
Sample Output:
45 is the maximum number
Program Code:
#include <stdio.h>
int findmaximum(int a,int b, int c)
{
int largest=0;
if(a>b && a>c)
largest=a;
else if(b>a && b>c)
largest=b;
else
largest=c;
return largest;
}
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("%d is the maximum number",findmaximum(a,b,c));
return 0;
}
Post A Comment:
0 comments: