Wednesday 9 March 2016

MAXIMUM OF 3


Write a C program to find the maximum of 3 numbers.

Input Format: 
Input consists of 3 lines. Each line consists of an integer.

Output Format: 
Output consists of a single line. Refer sample output for the format.

Sample Input : 
3
5
1

Sample Output : 
5 is the maximum number

Code:
  #include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  if(a>=b)
  {
    if(a>=c)
      printf("%d is the maximum number",a);
    else
      printf("%d is the maximum number",c);
  }
  else if(b>=c)
    printf("%d is the maximun number",b);  
    else
      printf("%d is the maximum number",c);
    
  return 0;
}

1 comment: