Page 43 - Modular_V2.0_C++_Flikpbook
P. 43

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;
                          }

                                                       In the lab                             21 st  Century   #Critical Thinking
                                                                                                 Skills

                          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 an equilateral triangle.


                  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.

                                                                                                                  41
                                                                                               Operators in C++
   38   39   40   41   42   43   44   45   46   47   48