Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Class XI
1. Distinguish between
a. Call by value and call by reference
b. Global variable and local variable
c. Constants and identifiers
d. Library functions and user defined
functions
e. Structure & array
f. a and a
g. a=5 and a = = 5
h. return and exit()
i. while and do while
j. entry controlled loop and exit
controlled loop
Computer Science
k.
l.
m.
n.
sqrt()
atoi()
random()
strcmp()
islower()
isupper()
Q.5
Do the following :
i) Find the error and write the code after doing the correction:
a)
const int x = 5;
int y = 9;
x = x+ y;
b)
char a[10] = Computer;
if ( a = Science)
cout << Computer ;
else
cout << Biology;
c)
char a[10];
a = Computer;
cout << a;
ii) What will be the result of following if I =10 ?
i) ++I <=10
ii) I++ <=10
iii) What is wrong with the following loops :
a) int counter = 1;
b)
int counter = 1;
while (counter < 100)
while (counter < 100)
{
cout << counter <<\n;
cout << counter <<\n;
counter ++;
counter --;
}
iv ) Write the equivalent while loop for given for loop:
for( int i=0, sum =0; i< sz; i++)
sum += i;
cout <<sum;
v) What are the outputs of following codes ? Justify your answer.
// Version 1
// Version 2
int f =1, i=2;
int f = 1, I = 2;
while (++i<5)
do {
f *= I;
f *=I;
cout <<f;
} while (++i<5);
cout <<f;
vi) Identify the problem in the following code:
#include<iostream.h>
void large(int &a, int &b)
{
if (a> b)
a = -1;
else
b = -1;
}
main()
{
const int x = 5;
const int y = 9;
large (x,y);
}
vii)
Will the following code execute successfully? (Assume all header files are included)
a) int s=10;
c)
int x = 10;
int &t;
void func1(const int &a)
void main()
{
{
a = 10;
t = s;
}
cout<<t;
main()
}
{
b) int x = 10;
int y = 5;
void func1(const &a)
func1 (y);
{
}
cout<<a<<endl;}
viii)
ix)
x)
xi)
xii)
void main()
{
int y = 5;
func1(y);
}
Which of the following are valid identifiers ?
Data_rec, roll number, 1 name, my.file, auto, goto, asm
Which of the following are the correct character constants in C++ ?
c,
abc,
abc \n;
Is the following statements are correct :
int v;
char code = v;
evaluate the following
int a,b,c;
float d,f;
a = 5;
b = 3;
d = 1.5;
(a) f = a + b/a
(b) c = d * a + b
(c) (a++) * d + a;
(d) f = (++b) * b a
(e) c = a (b++) * (- -d)
Evaluate
int a, mb = 2, k = 4;
float x, y = 60.0;
a = mb * 3 /4 +k / 4 + 8 mb + 5 / 8;
x = mb * 3 / 4 + y / 4 + 8 y + y / 8;
xiii)
What will be the value of the following, if j = 5, k = 5 and l = 2 ?
(a) ( 5 * ++j ) % 6
(b) (5 * j ++) % 6
(c) k = l = j++;
xiv) Element amount[9] is which element of the array ?
(a) the eighth (b) the ninth
(c) the tenth
PROGRAM
1.
2.
3.
4.
5.