Sunday 9 March 2014

Write a program to find greatest number from two numbers using if statement.

Write a program to find greatest number from two numbers using if statement.

Code for Program to find greatest number from two numbers using if statement in C Programming

#include <stdio.h>
main()
{
int i,j,big;  //variable declaration
scanf("%d%d",&i,&j); big = i;
if(big < j)   // statement A

{      // C
big = j;     
}     // D
printf("biggest of two numbers is %d \n",big);
if(i < j)  // statement B

    {
    big = j;   
    }
  else
    {
    big = i; 
    }
printf("biggest of two numbers(using else) is %d \n",big);
}

No comments:

Post a Comment