Conditional statements (IF)

Hii from Team(S.A.O.P)

today we are going to explain Sub-topic of Conditional statement which is If .

Conditional statements(IF):

An if statement consists of a Boolean expression followed by one or more statements.

syntax:

The syntax of an 'if' statement in C programming language is 
if(boolean_expression) {
      /* statement(s) will execute if the boolean expression is true */
}

If the Boolean expression evaluates to true, then the block of code inside the 'if' statement will be executed. If the Boolean expression evaluates to false, then the first set of code after the end of the 'if' statement (after the closing curly brace) will be executed.

As we all know C programming language assumes every non-zero or non-null values as true and if it is either Zero or null then it is assumed as false value.

Program:

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

int main()
{

int num1,num2,num3;

printf("June117.blogspot.com \n");

printf("IF-Conditional statement \n");
printf("Enter first number : ");
scanf("%d",&num1);

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

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

if(num1>=num2&&num1>=num3)
 printf("%d is greatest number",num1);

if(num2>=num1&&num2>=num3)
 printf("%d is greatest number",num2);

if(num3>=num1&&num3>=num2)
 printf("%d  is greatest number ",num3);

return 0;
}

lets assumed 
num1 = 5;
num2 = 3;
num3 = 6;

output:


summery:

In above program we have declare three integer num1 num2 num3.
In first If-condition we are comparing num1 to num2 and num1 to num3 using greater than equals to.
if(num1>=num2&&num1>=num3)  

In second If-condition we are comparing num2 to num1 and num2 to num3 using greater than equals to.
if(num2>=num1&&num2>=num3)  

In last If-condition we are comparing num3 to num1 and num3 to num2 using greater than equals to.
if(num3>=num1&&num3>=num2)  
thanks for reading our blog for more updates follow us
This Blog is presented by (S.A.O.P)127.0.0.1is heaven

Comments