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

compulsory questions xi cs

The document contains a series of compulsory questions and answers from various chapters of a computer science curriculum, focusing on programming concepts in C++. It includes examples of loops, class structures, destructors, and basic programming tasks such as displaying series and performing bitwise operations. The questions are categorized by exam dates from March 2019 to June 2024.

Uploaded by

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

compulsory questions xi cs

The document contains a series of compulsory questions and answers from various chapters of a computer science curriculum, focusing on programming concepts in C++. It includes examples of loops, class structures, destructors, and basic programming tasks such as displaying series and performing bitwise operations. The questions are categorized by exam dates from March 2019 to June 2024.

Uploaded by

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

XI CS COMPULSORY QUESTIONS

MARCH 2019
1. Write a while loop that displays numbers 5, 10, 15........ 50. (Chapter–10)
Answer:
int i = 5;
while(i <= 50)
{
cout << i;
i = i + 5;
}

2. (Chapter–14)

Answer:
(i) Members of the class are m, n, add() and calc()
(ii) Size of the object x1 in memory is 8 bytes.
Size of the object x2 in memory is 8 bytes.

JUNE 2019
1. 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.

2. Write a C++ program to print the following series: 1, 3, 5, 7 ….. 75(Chapter–10)


#include<iostream>
using namespace std;
int main( )
{
int i;
for(i = 1;i <=75; i = i + 2)
{
cout << i;
}
return 0;
}

1
MARCH 2020
1. (Chapter–14)

1. What is the name of the class in the above program?


2. What are the data members of the class?
3. What are the member functions of the class?
4. What is the memory size of the objects p1, p2?
5. Under which visibility mode, data members are declared?
6. Under which visibility mode, member functions are declared?
7. How many objects are created? What are they?

Answer:
1. The name of the class is product
2. Data members are code, quantity, price
3. Member functions are assigndata()andprint()
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 are created. They are p1 and p2

2. If a = 65, b = 15, then find

(i) a&b

(ii) a^b (Chapter–9)

2
Answer:
65 10 = 10000012
15 10 = 11112
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 = 1001110 2 = 7810

June 2020

1. for(int m = 1; m <= 9; m+= 2)


cout << m;
(i) How many times the loop will be executed?
(ii) Write the output of the above snippet. (Chapter–10)
Answer:
(i) 5 times
(ii) Output:
13579

(iii) (Chapter–16)

3
(a) Which type of inheritance is shown in the above snippet?
(b) Write the visibility mode of class marks and result.
(c) Name the base classes and derived classes in the above snippet.
Answer:
(a) Multi level 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 to10 using ‘for’ loop.(Chapter –10)
#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.

2. What is meant by computer Ethics?(Chapter–17)


 Computer ethics deals with the procedures, values and practices.
 It governs the process of consuming computer technology without damaging or violating the
moral values and beliefs of any individual, organization or entity.
March 2023
1. Write the output(Chapter–9)
#include <iostream>
using namespace std;
int main()
{
double var1=87.25255;
cout<<(float)varf<<endl;
cout<< (int) varf<<endl;
}
Output:
87.2525
87

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’ ;

2. Convert the following octal numbers into binary numbers.(Chapter–2)


(i) 6137
(ii) 245
(iii) 472
Answer:
(i) 6137
421 421 421 421
6 1 3 7
110 001 011 111
6137 8=1100010111112

(ii) 245
421 421 421
2 4 5
010 100 101
2458= 0101001012

(iii) 472
421 421 421
4 7 2
100 111 010
4728=100111010 2
5
March 2024
1. Write the output of the following program
#include<iostream>
using namespace std;
int main( )
{
int i;
for(i = 0; i < 8; i++)
cout << i << endl;
return 0;
}
Output:
0
1
2
3
4
5
6
7
2. Write a C++ program to display numbers from 5 to 1 using do-while loop
Program:
#include<iostream>
using namespace std;
int main( )
{
int i = 5;
do
{
cout << i ;
i--;
} while ( i > = 1 ) ;
return 0;
}

June 2024
1. Write a while loop that displays numbers 2, 4, 6, 8, …. , 20
int i = 2;
while( i < = 20 )
{
cout << i;
i = i + 2;
}

2. Write a C++ program to print multiplication table of a given number.


#include<iostream>
using namespace std;
int main()
{
int i , n ;
cout << “ enter a number “ ;
cin >> n;
for ( i = 1 ; i < = 10 ; i + + )
{
cout<< i << ‘ x ‘ << n << ‘ = ‘ << i * n << ‘ \ n ‘ ;
}
return 0;
}
6

You might also like