Sei sulla pagina 1di 3

Revision Questions- 1

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.

run time error and syntax error


getchar() and gets()
getch() and getche()
one dimensional array and two
dimensional array
o. fundamental data type and derived
data type
p. keywords and variables
q. selection and repeatition
r. if and switch statement

2. Name the header files for the following functions


clrscr()
setw()
gets()
toupper( )
islower()
randomize() pow()
abs()
strlen()
isalpha()
strlen()
strcpy()
isdigit()
strcat()
gotoxy()
puts()
cos()
3. Define the following:
a) Tokens
b) escape sequences
c) header file
e) user defined function
f) formal parameter
g) actual parameter
i) two dimensional array
j) structures
k) derived data types
m) punctuators
n) const
o)typedef
4.

sqrt()
atoi()
random()

strcmp()
islower()
isupper()

d) fundamental data types


h) array
l) literals
p) reference variable

Answer the following :


1) Explain types of literals in C++.
2) Why main() function is special ?Give two reasons .
3) What is the application of void data type in C++ ?
4) What is the purpose of default clause in a switch construct.
5) What is an array? How does it different from ordinary variable ?
6) What is meant by function prototype ?
7) What are scope rules of variables ?
8) What are default arguments ?
9) How many bytes are allocated to (a) int
(b)char
(c) float (d) double
10)Name two unary and two binary operators.
11)What is cascading of I/O operator ?
12)What is type conversion ?
13) What is type casting ?
14) Name two logical, relational and arithmetic operators.
15) What is conditional operator?
16) What do you understand by the index?
17) Write console Input and output operator.
18) What is base type of an array?
19) What is the last character of a string?
20)Name three iteration statements in C++.
21)What are the two ways to initialize an array?
22) Why character often treated as integer datatype?
23) What is the effect of the absence of break in switch-case statement ?
24) What is the purpose of comment and indentation in a program ?
25) Illustrate the use of #define in C++ to define a macro.
26) What are Nested Structures ? Give an example.
27) What is the difference between #define and const ? Explain with suitable example.
28) What is the purpose of using typedef command in C++. Explain with suitable example.

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.

WAP in C++ to find the sum of the digits of a given number.


Create a two-dimensional array and find the highest and lowest element of each row.
WAP to replace every blank space in a string with an * (asterisk).
WAP to count the number of times a given character is present in a string .
WAP that reads a string and a character. It then converts each sequence of the given character to
opposite case .
6. Write the functions :
(a) Write a function seqsum( ) in C++ with two arguments, double x and int n. The function
should return a value of type double and it should find the sum of the following series :
1 + x/2! + x2/4! + x3/6! + x4/8! + x5/10! + + xn/(2n)!
(b) Write definition for a function SumSeries() in C++ with two arguments/parameters double x and int
n. The function should return a value of type double and it should perform sum of the following
series :
x x2 / 3! + x3 / 5! x4 / 7! + x5 / 9! . . . upto n terms
(Note : The symbol ! represents Factorial of a number i.e.,
5! = 5 x 4 x 3 x 2 x 1
7. Write a program to find the sum of all the positive elements which are divisible by 2 or 3.

Potrebbero piacerti anche