Page 54 - C++
P. 54

(d)    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 Ar[ ] = { 6 , 3 , 8 , 10 , 4 , 6 , 7} ;
                                    int *Ptr = Ar , I ;
                                         cout<<++*Ptr++ << '@' ;
                                         I = Ar[3] - Ar[2] ;
                                         cout<<++*(Ptr+I)<<'@'<<"\n" ;
                                         cout<<++I + *Ptr++ << '@' ;
                                         cout<<*Ptr++ <<'@'<< '\n' ;
                                         for( ; I >=0 ; I -=2)
                                            cout<<Ar[I] << '@' ;
                             }

                      (e)    Find and write the output of the following C++ program code:                  (2)
                             typedef char STRING[80];
                             void MIXNOW(STRING S)
                             {
                                 int Size=strlen(S);
                                 for(int I=0;I<Size;I+=2)
                                 {
                                            char WS=S[I];
                                            S[I]=S[I+1];
                                            S[I+1]=WS;
                                    }
                                    for (I=1;I<Size;I+=2)
                                     if (S[I]>=’M’ && S[I]<=’U’)
                                            S[I]=’@’;
                             }
                             void main()
                             {
                               STRING Word=”CBSEEXAM2019”;
                               MIXNOW(Word);
                               cout<<Word<<endl;
                             }

                      (f)    Observe the following program and find out, which output(s) out of (i) to     (2)
                             (iv) willbe expected from the program? What will be the minimum and the
                             maximum value assigned to the variable Alter?

                             Note:  Assume all required header files are already being included in the
                             program.
                                    void main( )
                                    {
                                            randomize();
                                            int Ar[]={10,7}, N;

                                                              2
   49   50   51   52   53   54   55   56   57   58   59