TASK-
Write a function that returns the greater of the two numbers i.e. make a function that takes two integer arguments and returns the greater of the two. Write program to use this function.
CODE:
//Greater number would be found using logical operators >;
#include<stdio.h>
int great(int x,int y); //This the function of return type int and 2 int argument will be passed
int main(){
int num1,num2,g;
printf("Enter two numbers: "); // asking for two numbers which are going to be compared
scanf("%d%d",&num1,&num2); //Got numbers
g=great(num1,num2); //Passed two numbers to function and will get greater value in g
printf("\nGreater among two numbers is %d",g); //giving output as per requirement
getchar();
return 0;
}
int great(int x,int y) // defining function
{
if (x>y)
return x;// if x seems greater then y it will return x in to g;
return y; //else y returns to g;
}
EXPECTED OUTPUT:
💓💗
ReplyDelete