C Program to Find Greater Number by Using Function

0
3
digitalample eye
Write a program to find greater number using function.

Write a c program to take two numbers as input and check those numbers and display greater number.

Write a c program which take integer input a, b, c, d, e, f; and make three segments of these six variables to take input and find the greater number among two combinations by using functions

If you are looking for the program without using function take a look below, 
C Program to Find greater numbers without using functions

Don’t forget to declare and initialize function while writing code,

/*function prototype*/
int greater(int, int);

/*function definition*/
int greater(int x, int y) {
if(x>y)
return x;
else
return y;
}

C Code, 

#include <stdio.h>
#include <conio.h>

int greater(int, int);

void main()
{
int a, b, c, d, e,f;

printf("nenter two numbers;");
scanf("%d%d",&a, &b);

printf("n greater number is: %d", greater(a,b));

printf("nenter two numbers:");
scanf("%d%d",&c, &d);

printf("n greater number is : %d", greater(c,d));

printf("nenter two numbers:");
scanf("%d%d",&e,&f);

printf("n greater number is : %d", greater(e,f));

getch();
}
int greater(int x, int y)
{
if(x>y)
return x;
else
return y;
}

Output

greater number using function

LEAVE A REPLY

Please enter your comment!
Please enter your name here