Display Maximum number in c

Algorithm:

  • Start the program
  • Get two numbers from user
  • Stored the numbers in num1 & num1
  • If num1 is greater than num2 then num1 is maximum.
  • Else num2 is greater
  • Display the maximum number in output
  • Stop the program

Program:

#include <stdio.h>

int main()
{
int num1, num2;
printf(“Enter two numbers: “);
scanf(“%d%d”, &num1, &num2);
if(num1 > num2)
{
printf(“%d is maximum”, num1);
}
else
{
printf(“%d is maximum”, num2);
}

return 0;
}

Output:

Enter two numbers: 6
7
7 is maximum

Leave a comment