Compulsory Questions Xi Cs
Compulsory Questions Xi Cs
2. (Chapter – 14)
Answer:
(i) Members of the class are m, n, add( ) and calc( )
(ii) Size of the objects x1 in memory is 8 bytes.
Size of the objects x2 in memory is 8 bytes.
JUNE 2019
3. Write down the importance of Destructor. (Chapter – 14)
• The purpose of the destructor is to free the resources acquired by the object during its
lifetime.
• A destructor function removes the memory of an object which was allocated by the
constructor at the time of creating an object.
4. Write a C++ program to print the following series.1, 3, 5, 7…..75 (Chapter – 10)
Answer:
#include<iostream>
using namespace std;
int main( )
{
int i;
for(i = 1; i <= 75; i = i + 2)
{
cout<< i;
}
return 0;
}
1
MARCH 2020
5. (Chapter – 14)
Answer:
1. The name of the class is product
2. Data members are code, quantity, price
3. Member functions are assigndata( ) and print()
4. The memory size of the object p1 is 12 bytes
The memory size of the object p2 is 12 bytes
5. private
6. public
7. 2 objects. They are p1 and p2
6. (Chapter – 9)
2
Answer:
65 10 = 1000001 2
15 10 = 1111 2
65 1 0 0 0 0 0 1
15 0 0 0 1 1 1 1
65 & 15(AND) 0 0 0 0 0 0 1
Decimal 64 32 16 8 4 2 1
Decimal = 0 + 0 + 0 + 0 + 0 + 0 + 1 = 1
a & b = 65 & 15 = 1 2 = 1 10
65 1 0 0 0 0 0 1
15 0 0 0 1 1 1 1
65 ^ 15(XOR) 1 0 0 1 1 1 0
Decimal 64 32 16 8 4 2 1
Decimal = 64 + 0 + 0 + 8 + 4 + 2 + 0 = 78
a ^ b = 65 ^ 15 = 10011102 = 7810
June 2020
1. (Chapter – 10)
Answer:
(i) 5 times
(ii) Output:
13579
2. (Chapter – 16)
3
Answer:
(a) Multilevel inheritance
(b) The visibility mode of class marks is private
The visibility mode of class result is public
(c) The base classes are personal, marks
The derived classes are marks, result
MARCH 2022
1. What is the importance of void data type? (Chapter – 11)
void type has two important purposes:
• To indicate the function does not return a value
• To declare a generic pointer.
2. Write a C++ program to sum the numbers from 1 to 10 using ‘for’ loop.( Chapter – 10)
Answer:
#include <iostream>
using namespace std;
int main()
{
int i, sum;
sum = 0;
for(i = 1; i <= 10; i++)
{
sum = sum + i;
}
cout<< sum;
return 0;
}
June 2022
1. What is an instruction set?( Chapter – 3)
Basic set of machine level instructions executed by microprocessor is called as an instruction set.
4
2. Write a C++ program to display numbers from 1 to 10. Except 5 using for and continue statement.
(Chapter – 10)
Program:
#include <iostream>
using namespace std;
int main()
{
int i;
for(i=1;i <= 10;i++)
{
if (i == 5)
continue;
else
cout<< i;
}
return 0;
}
June 2023
1. Convert the following if-else statement into conditional statement: (Chapter – 10)
if (marks>= 60)
Grade=’A';
else
Grade=’B';
Answer:
Grade = (marks > = 60) ? ‘A’ : else ‘B’ ;
(ii) 245
421 421 421
2 4 5
010 100 101
245 8 = 0101001012
(iii) 472
421 421 421
4 7 2
100 111 010
472 8 = 100111010 2