Class 10 Computer Chapter 3 Notes

Complete Class 10 Computer Chapter 3 Notes Conditional Logic in 10th Class Computer Science English and Urdu Medium written by Honorable Mr. Wajid Ghani Suib. These computerized notes are very helpful in the preparation of Class 10 Computer Chapter 3 Notes for students of the 10th class Computer Science and these are according to the paper patterns of all Punjab boards.

Summary and Contents:
Topics which are discussed in the notes are given below:
  • Important 10 class computer chapter 3 mcqs for all students of Punjab  Textbook Board.
  • Important Multiple Choice Questions ( MCQs ) with correct Answers of Chapter No. 3: Conditional Logic in Computer Science class 10th Urdu Medium.
  • Important Short Questions with Correct Answers of Chapter No. 3: Conditional Logic in Computer Science class 10th Urdu Medium.
  • Important class 10 computer chapter 3 notes pdf for all students of Punjab  Textbook Board.
  • The associated code is any valid C language set of statements. It may contain one or more statements. The following flow chart shows the basic flow of an if statement.
  • Important class 10 computer chapter 3 important questions for all students of Punjab  Textbook Board.
  • If we want to associate more than one statements to an if statement, then they need to be enclosed inside a { } block, but if we want to associate only one statement, then although it may be enclosed inside { } block, but it is not mandatory. It is demonstrated through the following examples.
  • Important class 10 computer chapter 3 exercise solutions for all students of Punjab  Textbook Board.
  • EXAMPLE CODE:  #include  ,  void main()  , {   int a = 12;   ,  if (a % 2 == 0)   {   printf("The variable a contains an even value.");   ,   printf("\nYou are doing a great job.");   }   }   ,   Output:  The variable a contains an even value.,  You are doing a great job.
  • Important class 10 computer chapter 3 question answer for all students of Punjab  Textbook Board.
  • Because, when value 12 is divided by 2, it gives a remainder equal to 0, so the condition inside if parentheses is true. As both the printf statements are inside {} block, so both the statements get executed. Now look at the following example:
  • Important class 10 computer chapter 3 programming exercise for all students of Punjab  Textbook Board.
  • EXAMPLE CODE:  #include  , void main()  ,   {  int a = 4;  , int b = 5;   , if (a > b)  , printf("The value of a is greater than b.");   ,   printf("\nYou are doing a great job.");    }  ,  Output:  You are doing a great job.
  • Important class 10 computer notes chapter 3 for all students of Punjab  Textbook Board.
  • As the condition inside the if parentheses is false, and the statements following the if statement are not inside {} block, so only the 2nd statement is executed because without a {} block, only 1" statement is considered to be associated with the if statement.
  • Important class 10 computer chapter 3 short question answer for all students of Punjab  Textbook Board.
  • If-else Statement: Till now, we have demonstrated how to execute a set of instructions if a particular condition is true, but if the condition turns out to be false then we are not doing anything. What if we want to execute one set of instructions if a particular condition is true and another set of instructions if the condition is false.
  • Important class 10 computer chapter 3 pdf solutions for all students of Punjab  Textbook Board.
  •  In such situations we use if-else statement. It executes the set of statements under if statement if the condition is true, otherwise executes the set of statements under else statement.
  • Important class 10 computer chapter 3 exercise for all students of Punjab  Textbook Board.
  • General structure of the if-else statement is as follows:   if (condition)  ,  Associated Code  , else   ,  Associated Code
  • Important class 10 computer chapter 3 exercise solutions pdf for all students of Punjab  Textbook Board.
  • Associated code of if statement is executed if the condition is true, otherwise the code associated with else statement is executed. Following flow chart shows the structure of if-else statement.
  • Important class 10 computer chapter 3 extra questions for all students of Punjab  Textbook Board.
  • Important Note: An if statement may not have an associated else statement, but an else statement must have an if statement to which it is associated.
  • Important class 10 computer chapter 3 exercise solutions pdf download for all students of Punjab  Textbook Board.
  • Before else keyword, if there are multiple statements under if, then they must be enclosed inside the {} block, otherwise compiler issues an error. In order to understand this concept, let's look at the following example.
  • The above code cannot be compiled, because as discussed earlier, without a {} block only one statement is associated with if statement. 
  • Important class 10 computer chapter 3 exercise solutions urdu medium for all students of Punjab  Textbook Board.
  • In this case, the 1ª statement i.e. printf("The variable a contains an even value."); is associated with if statement, but the 2nd statement i.e. printf("\nYou are doing a great job."); is not associated with if statement. So, the else part is also disconnected from if statement. We know that an else block must be associated to an if block. In order to solve this problem, we can put both statements before else keyword inside {} block.
  • Important class 10 computer chapter 3 important long questions for all students of Punjab  Textbook Board.

Loading your document...