You are on page 1of 6

Holidays Homework of Winter vacation

Class-XI
1. Define
a. Token b. identifier c. literals d. operators e conditional
operator f. Escape sequence characters.
2. Identify keywords from the following:
a. double b. sizeof c. integer d. const e. default
f. while g. octal h. cout i. continue
3. Identify the character identifier:
a. ‘abc’ b. case c. “abc” d. Z2T0Z9 e. _CHK

f. my.file g. d_s_k h. return i. 29ABC j. data-my


4. What is the significance of ‘#’? What is the purpose of writing ‘#include’.
5. What is the specialty of UDF main( )?
6. What will happen if ‘#includes<iostream.h>’ is missing in your program
containing statements cout, cin, cerr?
7. Explain briefly comment entry and its types with examples.
8. What is Cascading of operators?
9. Fill in the Blank:
a. The program execution begins with __________________
b. Every main( ) with a return type int must end with a statement
__________.
c. Every executable statement must be terminated by ___________.
d. A ________ sequence of bytes and at lowest level, files is interpreted as
_________ of bytes.
e. The extension of program file is __________ , object file is ___________,
executable file is _________.
f. Shortcut keys for compilation is __________ and __________.
g. Shortcut keys for executing is __________ and __________.
h. Shortcut keys for making executable file is __________.
i. Shortcut keys for viewing output is __________.
10. Differentiate between the following:
a. ‘a’ and “a”. b. Keyword and Identifier. c.
11. What are predefined stream objects in I/O library?
12. What is code generator?
13. What is the significance of NULL (‘\0’) character in a string? What will be the
size of following strings:
a. “reema’s” b. “4%%%%%” c. “abc” d. “\a” e. “\\”
14. What is the difference between type casting and type conversion? Give
example.
15. Identify if the following are valid string, if yes give there length
a. “Computer Science” b. “A” c. “1234” d.”A1234”
16. Give the output of following program segment
void main() void main()
{ {
int a=10,b=8; int a=10,b=8;
for(int i=0;i<a;i++); for(int i=0;i<a;i++)
cout<<i<<endl; {
for(i=0;i<a;i++,b++) cout<<endl;
cout<<b<<endl; for(int j=0;j<i;j++)
} cout<<j<<”\t”;
}
}
void main() void main()
{ {
int a=5,b=8; int i,j,k,x=0;
for(int i=0;i<a;i++); for(int i=0;i<5;i++)
{ for(int j=0;j<I;j++)
cout<<i<<endl; {
for(int j=0;j<i;j++); k=i+j-1;
cout<<++j<<”\t”; if(k%2==0)
} x+=k;
b=a; else
++a; if(k%3==0)
b++; x+=k-2;
cout<<a<<”\t”<<b<<”\n”<<--b<<”\n”; cout<<x<<endl; }
} }
void main() void main()
{ {
for(int i=0;i<5;i++) for(int i=0;i<5;i++)
{ {
if(i==5) if(i==5)
break; continue;
cout<<i<<endl; cout<<i<<endl;
} }
} }
void main() void main()
{ {
int i=0;x=0; int i=0;x=0;
do for( i=1;i<10;i+=2)
{ {
if(i%5==0) x++;
{ cout<<x<<endl;
x++; }
cout<<x<<endl; cout<<x;
} }
++i;
}while(i<20);
cout<<”\n”<<x;
}
void main() void main()
{ {
int i,j,k,x=0; int i,j,k,x=0;
for(int i=0;i<5;i++) for(int i=0;i<5;i++)
for(int j=0;j<I;j++) for(int j=0;j<I;j++)
{ {
k=i+j-1; k=i+j-1;
if(k%2==0) if(k%2==0)
continue; break;
else else
if(k%3==0) if(k%3==0)
x+=k-2; x+=k-2;
cout<<x<<endl; } cout<<x<<endl; }
} }
#include <iostream.h> #include <iostream.h>
struct GAME void Secret(char Str[ ])
{ int Score, Bonus;}; {
void Play(GAME &g, int N=10) for (int L=0;Str[L]!='\0';L++);
{ for (int C=0;C<L/2;C++)
g.Score++;g.Bonus+=N; if (Str[C]=='A' || Str[C]=='E')
} Str[C]='#';
void main() else
{ {
GAME G={110,50}; char Temp=Str[C];
Play(G,10); Str[C]=Str[L-C-1];
cout<<G.Score<<":"<<G.Bonus<<endl; Str[L-C-1]=Temp;
Play(G); }
cout<<G.Score<<":"<<G.Bonus<<endl; }
Play(G,15); void main()
cout<<G.Score<<":"<<G.Bonus<<endl; {
} char Message[ ]="ArabSagar";
Secret(Message);
cout<<Message<<endl;
}

#include<iostream.h> #include<iostream.h>
#include<ctype.h> void Withdef(int HisNum=30)
void main( ) {
{ for(int
char Text[ ] = .Mind@work!.; I=20;I<=HisNum;I+=5)
for(int I=0; Text[I]!=.\0.;I++) cout<<I<<.,.;
{ cout<<endl;
if(!isalpha(Text[I])) }
Text[I]=.*.;
else if(isupper(Text[I])) void Control(int &MyNum)
Text[I]=Text[I] {
+1; MyNum+=10;
else Withdef(MyNum);
Text[I] = }
Text[I+1]; void main()
} {
cout<<Text; int YourNum=20;
} Control(YourNum);
Withdef();

cout<<.Number=.<<YourNum<<endl;
}

#include<iostream.h> #include<iostream.h>
#include<string.h> #include<conio.h>
#include<ctype.h> int g=20;
void Convert(char Str[ ],int void func(int &x,int y)
Len) {
{ x=x-y;
for(int y=x*10;
Count=0;Count<Len;Count++) cout<<x<<.,.<<y<<.\n.;
{ }
void main( )
if(isupper(Str[Count])) {
int g=7;
Str[Count]=tolower(Str[Count]); func(g,::g);
else if cout<<g<<.,.<<::g<<.\n.;
(islower(Str[Count])) func(::g,g);
cout<<g<<.,.<<::g<<.\n.;
Str[Count]=toupper(Str[Count]); }
else
if(isdigit(Str[Count]))
struct Pixel
Str[Count]=Str[Count]+1; {
else int C,R;
Str[Count]=.*.; };
} void Display(Pixel P)
} {
void main( )
{ cout<<.col.<<P.C<<.Row.<<P.R<<endl
char Text[ ]=.CBSE ;
Exam 2005.; }
int Size = strlen(Text); void main( )
Convert(Text,Size); {
cout<<Text<<endl; Pixel X={40,50},Y,Z;
for(int C=0,R=Size . Z=X;
1;C<=Size/2;C++,R--) X.C+=10;
{ Y=X;
char Temp=Text[C]; Y.R+=20;
Text[C]=Text[R]; Z.C-=15;
Text[R]=Temp; Display(X);
} Display(Y);
cout<<Text<<endl; Display(Z);
} }

Convert the following if to switch case


void main() void main()
{ {
int x; char x;
cin>>x; cin>>x;
if( x==10 || x==20) if( x==’A’ )
cout<<”\n Tens place”; cout<<”\n Alphabet A”;
else if (x==100 || x==200) else if (x==’B’ || x==’C’)
cout<<”\n Hundred place”; cout<<”\n Alphabet B or C”;
else if (x==1000) else if (x==’D’)
cout<<”\n Thousand place”; cout<<”\n Alphabet C”;
else else
cout<<”\n error “; cout<<”\n error “;
} }
Convert the following switch to nested if
void main() void main()
{ {
int x; char x;
cin>>x; cin>>x;
switch(x) switch(x)
{ {
case 20: case ‘1’:
case 22: cout<<x+40<<endl; case ‘2’: cout<<”\nprint value1”<<endl;
break; break;
case 40: case ‘3’:
case 60:cout<<x-40<<endl; case ‘4’:cout<<”\nprint value2”<<endl;
break; break;
case 80: cout<<x*20<<endl; case ‘5’: cout<<”\nprint value3”<<endl;
break; break;
default: cout<<”error”<<endl; default: cout<<”error”<<endl;
} }
} }

Convert the following for loop to do..while and while


void main() void main()
{ {
for(int i=0;i<5;i++) int sign=-1;
{ for(int i=1;i<=5;i++)
cout<<endl; {
for(int j=0;j<=i;j++) P=(i*i*i) *sign;
cout<<j; cout<<p<<”\n”;
} sign*=-1;
} }
}
Convert the following do..while to while and for
void main() void main()
{ {
int i=1,x=20; int i=1,x=20,a=0,b=1,c;
do cout<<a<<”,”<<b;
{ do
j=1; {
do c=a+b;
{ a=b;
cout<<j*5<<”\t”; b=c;
j++; cout<<”,”<<c;
}while(j<=i); i++;
cout<<i<<endl; }while(i<=x);
i++; }
}while(i<=x);
}

You might also like