You are on page 1of 7

OUTPUT QUESTIONS- XII STD I PART Q

1. Give the output of the following program segment : (assuming all


required header files are included in the program)
char *name = KenDriYa;
for (int x = 0; x < strlen(name); x++)
if (islower (name[x]} )
name[x] = toupper (name[x]);
else
if ( isupper (name[x]) )
if (x%2 != 0)
name[x] = tolower (name[x-1])
else
name[x]--;
cout << name << endl;}
2. Predict and explain the output of the following program :

#include <iostream.h>
int max (int &x, int &y, int &z)
{
if (x >y && y > z)
{
y ++;
z ++;
return x;
}
else
if (y >x)
return y;
else
return z;
}
void main ( )
{
int a = 10, b = 13, c = 8 ; a = max (a, b, c);
cout << a << b << c << endl; b = max (a, b, c);
cout << ++ a << ++ b << ++ c << endl; c = max (a, b, c);
cout << a++ << ++b << ++c << endl;
}
3.Give the output of the following program (Assuming all required header
files are included
in the program ).
2
void swap(char &c1,char &c2)
{ char temp;
temp=c1;
c1=c2;
c2=temp;
}
void update(char *str)
{
int k,j,l1,l2;

l1 = (strlen(str)+1)/2;
l2=strlen(str);
for(k=0,j=l1-1;k<j;k++,j--)
{
if(islower(str[k]))
swap(str[k],str[j]);
}
for(k=l1,j=l2-1;k<j;k++,j--)
{
if(isupper(str[k]))
swap(str[k],str[j]);
}
}
void main()
{
char data[100]={"gOoDLUck"};
cout<<"Original Data : "<<data<<endl;
update(data);
cout<<"Updated Data "<<data;
}
(5) Find the output of the following program:
#include<iostream.h>
struct MyBox
{
int Length, Breadth, Height;
};
void Dimension (MyBox M)
{
cout<<M.Length<<"x"<<M.Breadth<<"x";
cout<<M.Height<<endl;
}
void main ()
{
MyBox B1={10,15,5}, B2, B3;
++B1.Height;
Dimension(B1);
B3 = B1;
++B3.Length;
B3.Breadth++;
Dimension(B3);
B2 = B3;
B2.Height+=5;
B2.Length--;
Dimension(B2);
}
13. Find the output of the following program:
#include<iostream.h>
#include<ctype.h>

void main( )
{
char Mystring[ ] = "what@OUTPUT!";
for(int I=0; Mystring[I]!='\0';I++)
{
if(!isalpha(Mystring[I]))
Mystring[I]='*';
else if(isupper(Mystring[I]))
Mystring[I]=Mystring[I]+1;
else
Mystring[I] =Mystring[I+1];
}
cout<<Mystring;
}
14. Find the output.
#include<iostream.h>
void main( )
{
int U=10,V=20;
for(int I=1;I<=2;I++)
{
cout<<[1]<<U++<<&<<V 5 <<endl;
cout<<[2]<<++V<<&<<U + 2 <<endl;
}
}
15. Give the output of the following program segment(Assuming
all required header files are included in the program):
char *NAME=a ProFiLe;
for(int x=0;x<strlen(NAME);x++)
if(islower(NAME[x]))
NAME[x]=toupper(NAME[x]);
else
If(isupper(NAME[x]))
If(x%2!=0)
NAME[x]=tolower(NAME[x-1]);
else
NAME[x]--;
cout<<NAME<<endl;
16)Write the output of the following program:
#include<iostream.h>
int func(int &x,int y=10)
{ if(x%y==0) return ++x;else return y- -; }
void main( )
{
int p=20,q=23;
q=func(p,q);
cout<<p<<q<<endl;
p=func(q);

cout<<p<<q<<endl;
q=func(p);
cout<<p<<q<<endl;
}
17) Find the output of the following program:
#include<iostream.h>
#include<conio.h>
main( )
{
int number[10],a,b,c,d;
clrscr( );
for(int i=0;i<10;i++)
{
number[i]=i+i;
}
clrscr( );
for(int j=0;j<9;j++)
{
for(int k=j+1;k<10;k++)
{
if (number[j]>number[k])
{
a=number[j];
number[j]=number[k];
number[k]=a;
}
}
}
cout<<endl;
for(i=0;i<10;i++)
cout<<number[i]<<\t;i++;
getch( );
return 0;
}
18. Find the output of the following program:
#include <iostream.h>
struct Game
{
char Magic[20];int Score;
};
void main()
{
Game M={Tiger,500};
char *Choice;
Choice=M.Magic;
Choice[4]=P;
Choice[2]=L;
M.Score+=50;
cout<<M.Magic<<M.Score<<endl;
Game N=M;
N.Magic[0]=A;N.Magic[3]=J;
N.Score-=120;

cout<<N.Magic<<N.Score<<endl;
}

19.

Find the output


# define absolute(i) i>0 ? +i: -i
# define f(i) ++i
void main()
{ char *x= "Happy NEW yEaR 2014!";
int len= absolute(strlen(x));
for (int b = 0;b < len ; b++)
if (b%2 == 0)
x[f(b)] = x[b-1];
else
x[b] = x[b+1];
cout << "\nUpdated value ..." << x;
}
Give output
int Execute( int M)
{
if (M % 3 = 0)
return M * 3;
else
return M + 10;
}
void output( int B = 2)
{
for (int T = 0; T < B; T++)
cout << Execute(T) << *;
cout << endl;
}
void main()
{
output (4);
output ( );
output (3);
}
23. Give the output of the following program :
#include<iostream.h>
struct point
{
int x,y;
};
void showpoint p)
{
cout<<p.x<< :<<p.y<<endl;
}
void main()
{

point u = {20,10},V,W;
v=u;
v.x+=20;
w=v;
u.y+=10;
u.x+=5;
w.x-=5;
show(u);
show(v);
show(w);
}
Q 2(c)Consider the following and answer the following questions given below:
class School
{
int A;
protected:
int B,C;
public:
void INPUT(int);
void OUTPUT( );
};
class Dept:protected School
{
int X,Y;
protected:
void IN(int, int);
public:
void OUT( );
};
class Teacher:public Dept
{
int P;
void DISPLAY(void);
public:
void ENTER( );

};
(i) Name the base class and derived class of the class Dept.
(ii) Name the data member(s) that can be accessed from function OUT( ).
(iii) Name the private member function(s) of class Teacher.
(iv) Is the member function OUT( ) accessible by the objects of Dept?

You might also like