Page 153 - C++
P. 153

float A=3.2; B=4.1;

        C=Equation(A,B);

        cout<<'Output =’<<C<<endl;

        }

         (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.

        #include<iostream.h>
        struct pixel
        {
               int c, r;
        };
        void display(pixel p)
        {
               cout<<p.c<<” #“<<p.r<<endl;
        }
        void main( )
        {
               pixel x={40,50},y,z;
               z=x;
               x.c += 10;
               y= z;
               y.c += 10;
               y.r += 20;
               z.c -= 15;
               display(x);
               display(y);
               display(z);
        }
        (e) Find and write the output of the following C++ program code:                                     (2)

        #include<iostream.h>

        #include<ctype.h>

        #include<conio.h>

        #include<string.h>

        void changestring(char text[], int &counter)

        {

               char *ptr = text;

               int length=strlen(text);

               for(;counter<length-2;counter += 2, ptr++)
   148   149   150   151   152   153   154   155   156   157   158