Class 12 Computer Science Chapter 11 Notes

Important Notes of Class 12 Computer Science Chapter 11 Notes written by Professor Mr. Faraz Qasir Suib. These notes are very helpful in the preparation of Class 12 Computer Science Chapter 11 Notes of for the students of the intermediate 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:
  • Describe the need and organization of Control Structures: Answer : Control Structures : [Control structures are statements used to control the flow of execution in a program or function. The C control structures enable us to group individual instructions into a single logical unit with one entry point and one exit point]. Program instructions can be organized into three kinds of control structures to control execution flow i.e. sequence, selection and repetition. All programs, whether simple or complex, use these control structures to implement the program logic. Only sequential flow, is also called default flow. In case of sequence structure, instructions are executed in the same order in which they are specified in the program.
  • Describe the IF Statement? Explain test condition with an example: Answer : IF Statement : ”if” is one of the keywords in C language. It is used to select a path flow in a program based on a condition. A condition is an expression that either evaluates to true (usually represented by 1) or false (represented by 0). The result of this evaluation can be assigned to a variable. 
  • Describe Simple IF Statement? Explain it with diagram and an example.
  • Describe IF-ELSE Statement? Explain it with diagram and an example: Answer : IF-ELSE Statement : If statement is the simplest form of decision constructs. It allows a statement or a set of statements to be executed conditionally. The keyword else is used to specify two different choices with if statement. The general form of if-else statement is : if (condition) { Block of if (TRUE CASE) } 66 else { Block of else (FALSE CASE) } If the condition is TRUE, the block of if statement is executed and if the condition is FALSE, the block of else statement is executed. This flow chart explains the idea.
  • Describe Nested IF Statement? Explain it with diagram and an example: Answer : Nested IF Statement : Nested if statement means an if statement inside another if statement. Nesting can be done up to any level. The programmer may use as many (statements inside another if statement as (s)he wants. However, the increase in the level of nesting also increases the complexity of the nested if statement. The general form of nested if statement is : if (condition1) { Block of Outer if Begins if (condition2) { Block of INNER if } Block of Outer if Ends }.
  • Compare Nested if and Sequence of ifs and explain with example: Comparison of Nested if and Sequence of ifs : Due to the complexity of nested if statement, beginners usually prefer to use a sequence of if statements rather than a single nested statement. Sometimes, it is useful to use a nested if instead of sequence of ifs. In case of nested if statement, when the control flow reaches a logical decision, the rest of the conditions are skipped. Whereas in a sequence of if statements, all conditions are tested in any case.
  • Describe if-else-if Statement with data flow diagram and example.
  • Illustrate the use of Logical Operators giving example.
  • Illustrate the use of Switch Statement giving example.
  • Illustrate the use of Conditional Operator / Statement (ternary operator) giving example: Answer : Conditional Operator / Statement : Conditional operator is used as an alternative to the if-else statement. It is a ternary operator (requires three operand). Its general form is; conditional expression ? true-case statement false-case statement ; The expression may be a relational or logical expression.

Loading your document...