Page 123 - C++
P. 123
cout<<” Area is :”<<z<<endl;
}
d) Find the output of the following program.( assume all header files included) 2
void main ( )
{
char *str=”SCIENCE”;
int *p, num[]={ 3,5,7,9};
p=num;
cout<<*p<<str<<endl;
str++;
p++;
cout<<*p<<str<<endl;
}
Ans: 3SCIENCE
5CIENCE
e) Find the output of the following program.( assume all header files included) 3
class game
{
int phase, point;
char type;
public:
game( char gtype=’P’)
{
phase=1;
point=0;
type=gtype;
}
void play( int gs);
void change();
void show()
{
cout<<type<<”@”<<phase<<endl;
cout<<point<<endl;
}
};
void main()
{
game A(’G’),B;
B.show();
A.play(11);
A.change();
B.play(25);
A.show();
B.show();
}
void game::change()
{
XII / Comp. Sc. Page 2 of 17