0% found this document useful (0 votes)
19 views5 pages

Compulsory Questions Xi Cs

The document contains a series of programming exercises and answers related to C++ and computer science concepts from various chapters. It includes examples of loops, destructors, class members, and conversions between number systems. Additionally, it discusses computer ethics and the importance of the void data type.

Uploaded by

vennilavijay411
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Compulsory Questions Xi Cs

The document contains a series of programming exercises and answers related to C++ and computer science concepts from various chapters. It includes examples of loops, destructors, class members, and conversions between number systems. Additionally, it discusses computer ethics and the importance of the void data type.

Uploaded by

vennilavijay411
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

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 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)

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( ) 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.

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
245 8 = 0101001012

(iii) 472
421 421 421
4 7 2
100 111 010
472 8 = 100111010 2

You might also like