Conditional Statement

C Conditional Statement:

Conditional Statement is very important thing of any programming language. It is defined how we can control your program. C language has also Conditional Statement which is very easy. There are two types of Conditional Statement available in C language. These are --

  1. If-Else Statement
  2. Switch Case Statement

If-Else Statement:

In If Else Statement there are two parts One is if(condition){} and another is else{}.In if part in between the first bracket we need write the condition how we want to control our program and in between the curly bracket we need write our codes that we want to excute if condition safisfied. If the condition is not satisfy then it will autometially skip the code that we have been written in the { } of if statement. Else part excute if the condition is not satisfy of the If-statement.In the same way in bewtten the { } of Else statement we need to write the code and this code will excute if and only if the If-statement is not true.So that we can say everytime one part will excute either if part or else part . let's see how to implement the if-else statement.

    #include<stdio.h>
    int main(){
       
        if(condition){
        //your code will excute if condition is true.
        }
        else{
        //your code will excute if the if-part is false. 
        }
    return 0;
   }

Switch Case Statement:

Switch Case Statement is also help to contro our program and also work like if-else statement. The difference is Switch Case Statement works like a function on the other hand if-else is not work as a function.It can have sevarl blocks of statement and each blocks has condition as well. If one on condition will satisfy then the Compiler will excute that blocks of only .It have also default blocks but the default block only excute if any of blocks is not satisfy.Let's see how to implement Switch statement.

    #include<stdio.h>
    int main(){
       int condition;
       switch(condition){//condition holds value.
            Case constant1:
                //your code
                break;
                
            Case constant2:
                //your code
                break;
            . //to use more Case
            . 
            . 
            default:
                //your code                   
       }
    return 0;
    }
Best way of learing

Self learing is the best learing in the world. Discover yourself first then will get what you are And what you want to do .It will push you for self learing.

Why you need to learn coding?

Coding will play a vital role in one's life . It will help to open a new window of thinking . You can think better way than past . It helps to organise all the thing in better way .