Explain If Statement With Code And Examples
\\ If you have any query or questions on my post, then please comment below //
Control Flow Statement In C Programming:
Sometimes we want to execute some statement on one condition and the other statement executed on different condition. So for these kind of statement we need control flow statement. This controls the flow of statement that's why it is called control flow statement.
Control Flow Statement Types:
1. If Statement.
2. Switch Statement.
3. Go To Statement.
If Statement In C Programming:
What is if statement: The "if statement" is a powerful decision making statement and it is used to control the flow of execution of statements. It is mainly used in that place, where we want to manage more than one statement.
Syntax Of If Statement:
------------------------------------------------------------
if (test_condition)
{
-------------------- // Execution Code
-------------------- // Execution Code
}
--------------------------------------------------------------
Operational Syntax Of If Statement:
if(test_condition)
--------------------------------------------------------------
Example Of If Statement With Code And Explanation:
Write a program to input a number and print only when, the number is greater than 10.
Solution:
Here you see the main statement "Print Those Number Which Is Greate Than 10". So for this you have to use test _condition as "number>10", and if write the test_condition in if statement, then it should be like: if (number>10). Program:
--------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
void main()
{
int number;
clrscr();
printf("Enter The Number");
scanf("%d",number);
if(number>10)
{
printf("%d",number);
}
}
---------------------------------------------------------------------
I Hope you learn if statement very well, if you have any doubt then please comment below or ask question in the Facebook comment box. And Please Share And Like My Post To Your Facebook Post & With Friends.
Click Here To Know How To Download Above Video Tutorials Or YouTube Videos Free