Fbise Notes-Computer | Conditional Control Structure Long Questions Chapter No.4 10th class


conditional control structure

CONDITIONAL CONTROL STRUCTURE   CH NO.4



  LONG QUESTIONS

Q.No1 What is control structure? Explain conditional control structure with examples.


Ans: A conditional statement is an instruciton that contains a condition. When it is executed, the condition is evaluated and then based on result (true or false) a particular statement is executed. These statements in C language are if, if-else, else-if and switch statements.
            Conditional Control Structure:
                        The statement has the following structure e.g if statement.

            If (condition)
              {
                        Block of statements

              }

Example:        

#include <stdio.h>
#include <conio.h>
            void main (void)
            {
           
              Int marks;
            printf(“\n Enter your Marks:”);
            scanf(“%d ,&marks”);
            if  ( marks>32)
            {
                         printf(“\n Congratulations”);
                         printf(“\n You are Passed”);
                   }
                       
                        getch();
           
                        }   

   ➤➤➤➤➤➤➤➤➤➤➤➤ 




Q.No2   What is the purpose of switch( ) statement? Explain with the help                          of one example.


  Ans:  Switch() Statement:
The switch statement is similar to the else-if statement. It is used when multiple choices are given and one is to be selected.
1.       When switch statement is executed, the expression is evaluated.

2.       The result of the expression  is compared with the constant values.

3.       If the value matches then the statement under the case is executed.

4.       If no case is matched then the statement under the default keyword are executed.

5.       The break statement is to exit the body of switch statement.

Example:

#include <stdio.h>
#include <conio.h>
            void main (void)
            {
           
              Int n;
            printf(“\n Enter an integer, N:”);
            scanf(“%d ,&n”);
            switch(n)
            {
                               Case 1:
                                 printf(“N is 1”);
                                 break;

                              Case 2:
                                printf(“N is 2”);
                                break;
                 
                                                      .
                              default:
                                printf(“N is not  1 or 2”);
                  }
         getch();


   ➤➤➤➤➤➤➤➤➤➤➤➤ 


Fbise Notes-Computer | Conditional Control Structure Long Questions Chapter No.4 10th class Fbise Notes-Computer | Conditional Control Structure Long Questions Chapter No.4 10th class Reviewed by fbisenotes on July 25, 2019 Rating: 5

No comments:

Powered by Blogger.