MENU

Chapter 1 C plus plus Revision Tour Solutions

Question - 51 : -
Find the output of the following program :

#include
void Switchover(int A[], int N, int split)
for(int K=0;K
if(K
A[K]+=K; 
else
A[K]*=K;
}
void Display(int A[], int N)
{
for(int K=0;K
(K%2==0)?cout<
cout<< A[K]<
}
void main()
{
int H[]={30,40,50,20,10,5};
Switchover(H,6,3);
Display(H,6);
}

Answer - 51 : -

Output:
30%41
52%60
40% 25

Question - 52 : -
Find the output of the following program :

#include
struct GAME
Int Score, Bonus,
};
void Play(GAME &g, int N=100)
g.score ++; 
g.Bonus+=N;
void main()
{GAME G={110,50};
Play(G,10);
cout<
Play(G);
cout<
Play(G,15);
cout<
}

Answer - 52 : -

Output:
111 : 60
112:160
113:175

Question - 53 : -
Rewrite the following program after removing the syntax errors (if any). Underline each correction.

#include 
struct Pixels
{int Color<
void ShowPoint(Pixels P)
{
cout<
void main()
{
Pixels Pointl={5,3};
Show Point(Pointl); 
Pixels Point2=Point1;
Color.Point1+=2;
Show Point(Point2) ; 
}

Answer - 53 : -

#include 
struct Pixels
{int Color, Style}; 
void ShowPoint(Pixels P)
cout<
In cascading of Cout,<
void main()
{
Pixels Point1={5,3);    //{} to be used to initialise of members of the object
ShowPoint(Point1);
Pixels Point2=Point1;
Point 1.Color+=2;
ShowPoint(Point2);
}

×