Class 12 Computer Science Chapter 12 Notes

Important Notes of Class 12 Computer Science Chapter 12 Notes written by Professor Mr. Faraz Qasir Suib. These notes are very helpful in the preparation of Ch 12 Computer Science Class 12 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:
  • Important Class 12 Computer Science Chapter 12 Notes for Intermediate part-II students.
  • Describe Iteration and Loop: Answer : Iteration or Loop : There are problems whose solution may require executing a ,statement or a set of statements repeatedly. We need a structure that would allow repeating a set of statements up to fixed number of times or until a certain criterion is satisfied. [Iteration is the third type of program control structure (sequence, selection, iteration), and the repetition of statements in a program is called a loop]. Loop control statements are while, do-while, and for.
  • Describe While Statement with Flowchart and example: Answer : While Statement : [The while loop keeps repeating associated statements until the specified condition becomes false]. This is useful where the programmer does not know in advance how many times the loop will be traversed. The syntax of the while statement is : while (condition) { statement(s) ; } The condition in the while loop controls the loop iteration. The statements, which are executed when the given condition is true, form the body of the loop. If the condition is true, the body of the loop is executed. As soon as it becomes false, the loop terminates before starting next iteration.
  • Describe Do-While Statement with Flowchart and example.
  • Describe FOR Statement, its Execution Sequence, with flowchart and example: Answer : FOR Statement / Loop : The for statement is another way of implementing loops in C. Because of its flexibility, most programmers prefer the “for” statement to implement loops. The syntax of the for loop is : for (initialization expression ; test condition ; increment / decrement expression) { statement(s) ; // loop body } There are three expressions in for loop statement, these are : Initialization of the loop control variable. Test condition. Change (increment or decrement) of the loop control variable. for (stmt1; stmt2 ; stmt3) stmt4 ; 
  • Describe Nested Loop Statement with example: Answer : Nested Loop : Nested loop means a loop inside the body of another loop. Nesting can be done up to any level. But, as the level of nesting increases, the complexity of the nested loop also increases. There is no restriction on the type of loops (while, do while, or for) that may be placed in the body of other loops.
  • Define Sentinel Value ? Write an example program to show data entry by a user to calculate average marks of a student.
  • Describe goto Statement ? Explain it with Example Program: Answer : The goto statement performs an unconditional transfer of control to the named label. The label must be in the same function. A label is meaningful only to a statement; in any other context, the labeled statement is executed without regard to the label. The general form of the goto statement is as : goto label ; label: statement ; Example : Write a program to calculate the square root of a positive number (handle negative numbers properly). 

Loading your document...