C program to find larger number using function

If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().



#include<stdio.h>
main()
{
 void max();
 max();
}
void max()
{
 int n1,n2,n3;
 printf("Enter first number\n");
 scanf("%d",&n1);
 printf("Enter second number\n");
 scanf("%d",&n2);
 printf("Enter third number\n");
 scanf("%d",&n3);
 if(n1>n2&&n1>n3)
 {
  printf("%d is greater\n",n1);
 }
 else
 {
  if(n2>n1&&n2>n3)
   printf("%d is greater\n",n2);
  else
   printf("%d is greater\n",n3);
 }
}

OUTPUT:

Enter first number
5
Enter second number
7
Enter third number
12
12 is greater

Leave a Reply

Your email address will not be published. Required fields are marked *

4 × four =