Translate

Wednesday, April 22, 2020

The if-else statement

/*Control Statement:if else statement*/

*  Click Here, for Control Statement:-simple if statement

  •  The if-else Statement:

The if-else statement is a bi-conditional statement. in this statement, if the condition is true then the one part or program is executed otherwise other part of the program is executed.

The syntax of the if-else statement: 

if(condition is true)

   execute condition is true statement;
else
   execute condition is false statement;



The Flowchart of if-else statement: 


The Example of if-else statement: 

#include<stdio.h>
#include<conio.h>
void main()
{
    int num;
    printf("enter a number less than 5 =");
    scanf("%d",&num);
    if(num<5)
     printf("Good Your input is correct");
   else
     printf("Oops!! Your input is Incorrect");
     getch();
}

Output:

No comments:

Post a Comment

C program to make a calculator using the switch statement.

/*perform arithmetic calculation on integers in C language*/ #include<stdio.h> #include<conio.h> void main() {     char op;     ...