/Write a c program to find maximum of two numbers using if statement

If statement :

In c , the if statement is used to execute a block of code only if a specified condition is true. 

Syntax :

if ( condition)
{
// Code to execute if condition is true 
}


C program example code :

//Write a c program to find maximum of two numbers using if statement

#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);
}
if(num2>num1)
{
printf("%d is maximum",num2);
}
if(num1==num2)
{
printf(" both are same");
}
}

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post