Programming

C Program to Find Greater Number by Using Function

Write a c program that takes 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

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.