Page 34 - Modular_V1.1_Flipbook
P. 34

3.   void main()                                   4.   void main()

                           {                                                   {
                                int mrk1, mrk2, mrk3;                              int x = 4, y = 3, z = 6;
                                int total;                                         x = ++z + ++y / z;
                                char grade;                                        cout<<”value of x is: “<<x;
                                mrk1 = 80;                                    }
                                mrk2 = 90;
                                mrk3 = 78;
                                total = mrk1 + mrk2 + mrk3;
                                grade = (total >= 200)? ‘A’ :’B’;

                                cout << “Grade is: “ << grade;
                           }
                                                                                                         Critical Thinking
                                                        In the lab



                           Write a program to convert the given number of days into months and days.
                          (Consider 30 days = 1 month)
                          Type the following program and see the output:
                          #include<iostream.h>
                          #include<conio.h>
                          void main()
                          {
                          int a, b;
                          a = 20;
                          b =-10;
                          clrscr();
                          a = ++a;
                          cout <<”The new value of a is: “ << a << “\n “;
                          b = ++b;
                          cout <<”The new value of b is: “ << b << “\n “;
                          a = a * --b;
                          cout <<”The new value of a is: “ << a << “\n “;
                          a = a + 154;
                          cout <<”The new value of a is: “ << a << “\n “;
                          b = a++ * b;
                          cout <<”The new value of b is: “ << b << “\n “;
                          getch();
                          }
                          Write a C++ program to calculate the perimeter of a triangle with the same sides.


                   Teacher's Corner


                  1.   Explain the use of different types of operators provided by C++ to the students.
                  2.   Discuss the requirement of typecasting with the students.

                  32      Touchpad MODULAR (Version 1.1)-X
   29   30   31   32   33   34   35   36   37   38   39