3/10/21

IF-Else Condition in C Programming Part - 1


If Else Condition in C Programming 

Hey Friends, in day-to-day life people take a lot of decisions by themselves. For ex:- 

1. If it rains today, then I will not go to college

        If not then I will go

2. If the train is late, I will catch the train

        If not, I will not be able to get the train

Taking decisions in programming is an important part of it. C language also uses decision instruction. In C Programming there are mainly 3 types of decision control instruction

1. If 

2. If-else

3. Switch 

Till now we have studied sequence control instruction. In that instruction, Statements are executed in the order in which they have written or appear. But During the high-level projects, we need to execute a set of instructions by conditions. If the first condition is true then code will run or if the condition is not true (false) then the other condition runs or execute. 

So the selection of the condition (true or false) of instructions is called Decision.  

Now, In this article, we gonna learn about decision control instruction. 

If Statement in C programming 

In C programming, (if) is a keyword to execute an instruction if the instruction is true.  In Simple World, if the given condition is true your code will be run. If not then the code didn’t run. 

The Syntax of the if the condition was given below:- 

If (condition)

{

Statement 1;

Statement 2;

Statement 3;

}

Let us Check through an example :- 

#include <stdio.h>

int main()

{

int a;

printf("Enter the Number = ");

scanf("%d", &a);

if (a<=10)

    {

        printf("A is Smaller than 10");

    }

return 0;

}

Output:- 

Look at the function of the code:- 

In this program, we take a numeric input from the user to check whether a number is greater than 10 or smaller than 10.

If the numerical number is smaller than 10. Then the output will display a message to the user that your input is smaller than 10. 

But if the number is greater than 10. Nothing will be shown on the display. Because we give only one statement in this program.

So that’s all for today guys.. we will continue the rest of the function in the next part of the article. if you have any query related to this comment below. 

"+y+""}else{if(A==5){c+='
  • '+w+""+y+"
  • "}else{if(A==6){c+='
  • "+w+'
    '+u+""+y+"
  • "}else{c+='
  • "+w+"
  • "}}}}}s.innerHTML=c+=""+y;d.callBack()};randomRelatedIndex=h;showRelatedPost=g;j(d.homePage.replace(/\/$/,"")+"/feeds/posts/summary"+e+"?alt=json-in-script&orderby=updated&max-results=0&callback=randomRelatedIndex")})(window,document,document.getElementsByTagName("head")[0]); //]]>

    1 comment:

    Follow on Twitter

    Linkedin

    Categories

    Mad About Computer. Powered by Blogger.
    This site is in no way affiliated with or endorsed by specified business. It exists as a compendium of supporting information intended for informational purposes only. If you want to buy this website, please don't hesitate to contact us via e-mail: "d e n a c c 9 7 7 (at) g m a i l (dot) c o m" (delete spaces) or you can find and buy it on Afternic domain auctions.