0% found this document useful (0 votes)
57 views

Revision Assignment Class XI (Computer Science

This document contains a revision assignment with multiple questions covering topics in C++ such as data types, operators, control structures, functions, arrays, and classes. It asks the student to determine the validity of code snippets, define concepts, differentiate between terms, find outputs of programs, and write functions to solve problems involving arrays, matrices, and strings.

Uploaded by

Aastha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Revision Assignment Class XI (Computer Science

This document contains a revision assignment with multiple questions covering topics in C++ such as data types, operators, control structures, functions, arrays, and classes. It asks the student to determine the validity of code snippets, define concepts, differentiate between terms, find outputs of programs, and write functions to solve problems involving arrays, matrices, and strings.

Uploaded by

Aastha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Revision Assignment

Class XI( Computer Science(083)


Q1 (a) What is the significance of Null statement in c++?
(b) Define compound statement with example.
(c) Give the difference between Actual parameters and formal Parameters. Support your answer
with appropriate examples.
(d) Check if the following statements are valid or not, if not give reasons
1. int x(3);
2. a=3+12%5*5; cout<<x; the output is 13
3. double x(1/10); cout<<x; the output is 0.0
4. const a=90;
5. char s[]={‘a’,’b’,’c’}; cout<<sizeof(s); the output is 3
6. if (5<6) cout<<”hello”; cout<<endl; else cout<<”error”;
7. if (x) cout<<x; else cout<<”error”;
8. int x=071; cout<<x; the output is 71
9. int a=0x13; cout<<a; the output is 13
10. cout<<”hello\b\thi”; the output is hello hi
(e) What is the difference between keyword and identifier?
(f) What is the difference between ‘a’ and “a” in c++?
(g) What will be the result of following two expression if i=10 initially?
(i) ++i<=10 (ii) i++<=10
(h) Differentiate between CALL by reference and CALL by value. Give appropriate example to
support your answer.
(i) how many times the following loop will be executed:
1. while(1) { }
2. int c=0; while(c<10) cout<<c; c++;
3. int i=0 while(++i<10) cout<<i;
4. int i=0; while(i++<10) cout<<i;
5. while(x) { } the value of x=1;
(k) What is type casting? How it is different from implicit conversion. Give example to support your
answer.
Q2.
(a) Find out legal and illegal(if illegal give reason) :-
1) float interest (float principal=2000, int time=2, float rate);
2) float average(a,b);
(b) Find the output of the following code if the input given is 3:
int num, rndnm;
cin>>num;
rndnm= random( num) + 7;
for( int n=1; n<= rndnm; n++)
cout<<n<<” “ ;
1) 1 2 3 4 5 6 7 8 9 10 11
2) 0 1 2 3 4 5 6 7
3) 1 2 3 4 5 6 7 8 9
4) 1 2 3 4 5 6 7 8 9 10
(c) What will be the sizes of the following constants: ‘\a’, “\a”, “Reema\’s”, ‘\”’.
(d) What is polymorphism or function overloading? Give an example illustrating polymorphism.
State the ambiguities of function overloading.
Q3(a). Find the output: void main()
void show()
{
{
static int x=5;
for (int x=1;x<=3;x++)
cout<<x<<endl; show();
x++; } }
(b) What will happen if we give auto in place of static?
(c ) What is the difference between global and local variable. Give example.

Q4Give the difference and syntax of the following functions:


(a) getch() , getche(), getchar()
(b) gets(),cin.getline()
(c) puts(),cout.write()

Q5. Find the output of the code below:


a) void main( )
{
int NoOfGirls = 4;
int NoOfBoys = 10 ;
if ( NoOfBoys = 8 && NoOfGirls <= NoOfBoys )
cout<<”Great achievement”;
else cout<<”Greater achievement”; }

b). Find the output of the code below :


void main( )
{
int circle = 5 , rectangle = 0 , square = 4 , triangle = 0 ;
if( circle)
{
if( rectangle || square )
{
cout<<”Draw diagram”;
}
else if( ! rectangle && ! square )
{
cout<<”Invalid diagram”;
}
else
{
if( circle == rectangle || square == triangle )
{
cout<<”Canvas Available”;
} } }
cout<<”Invisible diagram”;
}

c. Find the output of code below:


void main( )
{
int x = 3 , y = 5;
if( x <= 5 );
cout<<”Hurray”;
else
cout<<” Trapped”;
}

d. In the following program, find the correct possible output(s)from the options:
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
char Area[ ][10]={“ NORTH”, “SOUTH”, “EAST”, “WEST”};
int ToGo;
for(int I=0; I<3;I++) {
ToGo=random(2) + 1;
cout<<Area[ToGo]<<”:”; } }
Outputs:
(i) SOUTH : EAST : SOUTH : (ii) NORTH : SOUTH : EAST :
(iii) SOUTH : EAST : WEST : (iv) SOUTH : EAST : EAST :

e. Find the output of the following program


#include<iostream.h>
#include<string.h>
#include<ctype.h>
void Convert(char Str[ ],int Len)
{ for(int Count=0;Count<Len;Count++)
{ if(isupper(Str[Count]))
Str[Count]=tolower(Str[Count]);
else if (islower(Str[Count]))
Str[Count]=toupper(Str[Count]);
else if(isdigit(Str[Count]))
Str[Count]=Str[Count]+1;
else Str[Count]=.*.;
}}
void main( )
{ char Text[ ]=”CBSE Exam 2005”;
int Size = strlen(Text);
Convert(Text,Size);
cout<<Text<<endl;
for(int C=0,R=Size . 1;C<=Size/2;C++,R--)
{ char Temp=Text[C];
Text[C]=Text[R];
Text[R]=Temp; }
cout<<Text<<endl; }

f) Find the output of the following program.


#include<iostream.h>
void Withdef(int HisNum=30)
{ for(int I=20;I<=HisNum;I+=5)
cout<<I<<”,”;
cout<<endl; }
void Control(int &MyNum)
{ MyNum+=10;
Withdef(MyNum); }
void main()
{ int YourNum=20;
Control(YourNum);
Withdef();
cout<<.Number=.<<YourNum<<endl; }

g) Find the output of following program segment:


#include<iostream.h>
struct three_d
{ int x,y,z; };
void movein(three_d &t, int step=1)
{ t.x+=step;
t.y+=step;
t.z+=step; }
void moveout(three_d &t, int step=1)
{ t.x-=step;
t.y+=step;
t.z-=step; }
void main()
{ three_d t1={10,20,5},t2={30,10,40};
movein(t1);
moveout(t2,5);
cout<<t1.x<<","<<t1.y<<","<<t1.z<<endl;
cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl;
movein(t2,10);
cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl; }
h) Find the output of following program segment:
#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; }

b. Write a function SumArray() which takes 2 parameters an integer array and its size and
displays sum of even and odd elements in the array.
c. Write a function Sum() which takes 2 parameters a 2-D square matrix and displays sum of the
elements which end with 3
d Write a function which takes a string as parameter and displays no of uppercase, lowercase,
digits and special characters.

You might also like