Today's topic

 

If-else    ladder

 

increment - decrement

 

Logical operators

 

Swapping

              Increment  and  Decrements

  • Post Increment   like      a++
  • Pre Increment     like      ++a             

a++;      <=>      a=a+1;

++a;       <=>      a=a+1;  

 

So what's the difference between them?

#include<stdio.h>

void main()

{

           int a,b,c;

           a=5;

           b=a++;

           c=++a;

           printf("b is %d",b);

           printf("c is %d",c);

           printf("a is %d",a);

}

Output

 

b is 5

c is 7

a is 7

Swapping

a=2;

b=3;

 

after swapping

 

a=3;

b=2;

Question

 

Write a program to take two integer as input from user and swap their values.

Logical operators

 

       &&           AND              if(a && b){}

       ||            OR                 if(a || b){}

        !              NOT               if(!(a==b)){}

 

Nested If else

if (cond1)
    {
         if(cond2)
            {       
                statement0;
            }
    
         else 
            {     
                statement1;
            }
    }

else 
    {
        statement2;  
    }

Questions

</>

deck

By MRITUNJAY GOUTAM