Thursday, February 11, 2016

C Program to find largest number from given three numbers.

#include<stdio.h>
int main()
{
int num1, num2, num3;

  printf("Enter number1:");
  scanf("%d",&num1);

  printf("Enter number2:");
  scanf("%d",&num2);

  printf("Enter number3:");
  scanf("%d",&num3);

  if(num1 > num2 && num1 > num3)
  {
    printf("Number1 is largest number.");
  }
  if(num2 > num1 && num2 > num3)
  {
    printf("Number2 is largest number.");
  }
  if(num3 > num1 && num3 > num2)
  {
    printf("Number3 is largest number.");
  }
    return 0;
}
/*
Enter number1:5
Enter number2:4
Enter number3:3
Number1 is largest number.
*/
//Note: Add logic to update this program when two/three numbers are same.

No comments:

Post a Comment