If Else

DECISION MAKING STATEMENTS

  1. What is need of Decision making statements?
  2. See Answer Ans: When we want to make a choice among two or more statements, then decision making statements are needed mostly.

  3. How many types of Decision making statements?
  4. See Answer Ans: 4 Types.
       1. Simple If    2. if-else    3. Ladder if-else    4. Nested if-else

  5. What is the importance of blocks?
  6. See Answer Ans: When more than one statements want to execute in the if condition and else statement then we must need to create blocks.

  7. When else blocks become necessary?
  8. See Answer Ans: Else blocks are very necessary to create because when more than one statement is made in the else blocks, because if we don't create else blocks then the statements given in the else are treated as common statements except Ist statement.

  9. When to use Ladder if-else?
  10. See Answer Ans: Generally, When more than two conditions are given we use ladder-if-else.

  11. When to use nested if-else?
  12. See Answer Ans: When a condition depends on another condition to execute then we use nested if-else.

  13. How logical operator AND(&&)works?
  14. See Answer Ans: In AND(&&) Operator, If all conditions are true then the result wiil be true. When one othe given conditions is false, the result will become false. When, one condition is false then any other condition will not be check in AND(&&) operator.

  15. What is the difference between =(Assignment Operator) and ==(equality operator).
  16. See Answer Ans: Assignment operator(=) assign the values from left to right eg. x=5; Equality operator(==) check the equality whether a value is equal to another value or not? eg. if(a==b) or not?

  17. What will be the output of:
    • if(!7<=10)
      printf("Banglore Computer");
      else
      printf("Education");
    • See Answer Ans: Bangalore Computer

  18. What will be the output of:
    • if(7)
      printf("Hello");
      else
      printf("Hi");
    • See Answer Ans: Hello

  19. What will be the output of:
    • if(2==3);
      printf("Real");
      else
      printf("Java");
    • See Answer Ans: Error at if(2==3);

  20. What will be the output of:
    • if(2==3)
      printf("Real");
      else
      printf("Java");
    • See Answer Ans: Java

  21. What will be the output of:
    • if(printf("Hello"))
      printf(" Real");
      else
      printf(" Java");
    • See Answer Ans: Hello Real