EVALUATE THE OUTPUTS (12-CBSE-C++,SECTION-A):
Find the output of the following C + + program code:
Note Assume all required header files are already being included.
(1) void Change (int a = 25)
{
for(int I=10;I<=a;I+=4)
cout<<I<<" ";
cout<<endl;
}
void UPdate(int &n)
{
n += 20;
change (n);
}
void main()
{
int C = 15;
UPdate(C);
Change() ;
cout<<"Number="<<endl;
}
=======================================================================
(2) class TEACHER
{
int Tid, TeachCode, TeacherCount;
public:
TEACHER(int Thid=l)
{
Tid = Thid;
TeachCode=0;
TeacherCount=0;
}
void Subject(int S=20)
{
TeachCode++;
TeachCount+=S;
}
void Status()
{
cout<<Tid<<":"<<TeachCode<<":"<<TeacherCount<<endl;
}
};
void main()
{
TEACHER T(5),M;
T.Subject();
M.Subject(50);
T.Status();
T.Subject(30);
M.Status();
T.status();
}
=======================================================================
(3) int a=20;
void main()
{
void func(int &, int, int *);
int a=50,b=20;
func(a,::a,&b);
cout<<"\n"<<a<<"\t"<<::a<<"\t"<<b;
}
void func(int &x,int y,int *z)
{
a += x;
y *= a:
*z = a+y;
cout<<"\n"<<x<<"\t"<<y<<"\t"<<b;
}
========================================================================
Note Assume all required header files are already being included.
(1) void Change (int a = 25)
{
for(int I=10;I<=a;I+=4)
cout<<I<<" ";
cout<<endl;
}
void UPdate(int &n)
{
n += 20;
change (n);
}
void main()
{
int C = 15;
UPdate(C);
Change() ;
cout<<"Number="<<endl;
}
=======================================================================
(2) class TEACHER
{
int Tid, TeachCode, TeacherCount;
public:
TEACHER(int Thid=l)
{
Tid = Thid;
TeachCode=0;
TeacherCount=0;
}
void Subject(int S=20)
{
TeachCode++;
TeachCount+=S;
}
void Status()
{
cout<<Tid<<":"<<TeachCode<<":"<<TeacherCount<<endl;
}
};
void main()
{
TEACHER T(5),M;
T.Subject();
M.Subject(50);
T.Status();
T.Subject(30);
M.Status();
T.status();
}
=======================================================================
(3) int a=20;
void main()
{
void func(int &, int, int *);
int a=50,b=20;
func(a,::a,&b);
cout<<"\n"<<a<<"\t"<<::a<<"\t"<<b;
}
void func(int &x,int y,int *z)
{
a += x;
y *= a:
*z = a+y;
cout<<"\n"<<x<<"\t"<<y<<"\t"<<b;
}
========================================================================
No comments
Post your comments