Page 68 - Modular_V1.1_Flipbook
P. 68

2.   int i = 1;                                       3.   int sum = 0;

                           while (i <5)                                           for (int i = 0; i <= 10; i++)
                           {                                                            sum = sum + i;
                                   cout << i;                                           cout << sum;
                                   i = i * 2;
                           }

                       4.  int r = 5, c = 3;
                             for (int i = 1; i <= r; ++i) {

                                   for (int j = 1; j <= c; ++j) {
                                   cout << “*  “;
                           }

                           cout <<”\n”;
                           }
                                                                                                           Creativity
                                                                                                         Critical Thinking
                                                        In the lab



                      Write a program to:
                          print the numbers 100, 98, 96, . . . , 4, 2.
                          print the cubes of first 10 natural numbers.

                          find the sum of even numbers between 1 and 100.
                          display the following series:
                          4, 16, 36, 64, 100, …. , 400
                          display the Fibonacci series
                          e.g., 0, 1, 1, 2, 3, 5, 8.........
                          calculate the factorial of numbers from 1 to 10.
                          print the following pattern
                                A

                              ABA
                             ABCBA
                            ABCDCBA
                           ABCDEDCBA





                   Teacher's Corner


                  1.   Discuss looping statements with the students.
                  2.   Explain the use of jump statements to the students.





                  66      Touchpad MODULAR (Version 1.1)-X
   63   64   65   66   67   68   69   70   71   72   73