Page 273 - C++
P. 273

(d)     Find and write the output of the following C++ program code :                   2
                   Note : Assume all required header files are already included in the
                   program.

                   #define Diff(N1,N2) ((N1>N2)?N1-N2:N2-N1)
                   void main()
                   {

                       int A,B,NUM[] = {10,23,14,54,32};
                       for(int CNT =4; CNT>0; CNT--)
                       {
                             A=NUM[CNT];

                             B=NUM[CNT-1];
                             cout<<Diff(A,B)<<'#';
                       }
                   }

           (e)     Find and write the output of the following C++ program code :                   3

                   Note : Assume all required header files are already being included in
                   the program.


                   void main()
                   {
                       int *Point, Score[]={100,95,150,75,65,120};
                       Point = Score;

                       for(int L = 0; L<6; L++)
                       {
                             if((*Point)%10==0)

                                  *Point /= 2;
                             else
                                  *Point -= 2;
                             if((*Point)%5==0)
                                  *Point /= 5;

                             Point++;
                       }
                       for(int L = 5; L>=0; L--)

                          cout<<Score[L]<<"*";
                   }
      91                                             3                                        P.T.O.
   268   269   270   271   272   273   274   275   276   277   278