Simple IF ELSE Statement
if statement evaluates the condition inside the paranthesis and if it is true, then it executes one line followed by if statement or the sequence of steps bound of { }.
if statement can be combined with else part. Else part will be executed when the if condition is false.
Source Code
#include <stdio.h>
void main()
{
int x;
printf("Enter a Number: ");
scanf("%d", &x);
if(x < 0)
printf("%d is a negative number\n", x);
else
printf("%d is a positive number\n", x);
}
Output
Enter a Number: -100
-100 is a negative number
Enter a Number: 55
55 is a positive number
#include
উত্তরমুছুনmain()
{
int y=2;
printf("enter a number");
if (y<0)
printf("%d is a negative number\n",y);
else
printf("%d is a positive\n",y);
}
#include
উত্তরমুছুনmain()
{
int y=2;
printf("enter a number");
if (y<0)
printf("%d is a negative number\n",y);
else
printf("%d is a positive\n",y);
}
///simple if else statement///
উত্তরমুছুন#include
int main()
{
int n;
n=10;
if(n>=0)
{
printf("The number is positive\n");
}
else
{
printf("The number is negative\n");
}
return 0;
}
### simple if else statement ###
উত্তরমুছুন#include
main()
{
int a,b;
scanf( "%d"& a );
scanf( "%d"& b );
if(a<b)
printf( "b is big" );
else
printf ( " a is big ");
}