0% found this document useful (0 votes)
6 views2 pages

Class_12_CS_Notes_ReportLab

The document contains multiple-choice questions (MCQs) with answers related to programming concepts, including operators and data types. It also includes short questions about header files, escape sequences, and variable definitions, along with their answers. Additionally, several C++ programs are provided to demonstrate reading input and calculating values such as temperature conversion, area, sum, product, and average.

Uploaded by

zafarmahmood547
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)
6 views2 pages

Class_12_CS_Notes_ReportLab

The document contains multiple-choice questions (MCQs) with answers related to programming concepts, including operators and data types. It also includes short questions about header files, escape sequences, and variable definitions, along with their answers. Additionally, several C++ programs are provided to demonstrate reading input and calculating values such as temperature conversion, area, sum, product, and average.

Uploaded by

zafarmahmood547
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/ 2

MCQs with Answers

1. Which of the following is equal to operator? b. == 2. The number of bytes reserved for a variable of
data type float is b. 4 3. Which operator is used for compound condition? d. Logical 4. Which of the
following is an arithmetic operator? b. % 5. Which one of the following is ignored during program
execution? b. Comment 6. What is the range of unsigned short integer? c. 0 to 65535 7. In C++ the
expression sum = sum + n can also be written as a. sum += n 8. How cursor is moved to the next
tabular position for printing data? b. By using manipulator 9. Which sign is used for logical AND? d. &&
10. Which one is called modulus operator? b. %

Short Questions with Answers


Q1. What is the purpose of using header files in a program? Answer: Header files contain prewritten
code like function declarations, making it easier to use features like input/output. Q2. Why escape
sequences are used? Give three examples with explanation. Answer: Escape sequences control the
formatting of output. Examples: - \n : Move to new line - \t : Insert tab space - \\ : Print backslash Q3.
Define variable and write the rules for specifying variable names. Answer: A variable is a named
location in memory used to store data. Rules: - Must start with a letter or underscore. - Cannot have
spaces or special characters. - Cannot use reserved keywords. (More short answers included)

Long Questions with Answers


Q1. Write a program that reads temperature in Fahrenheit and prints its equivalent in Celsius:

#include<iostream>
using namespace std;
int main() {
float f, c;
cout << "Enter Fahrenheit: ";
cin >> f;
c = 5.0/9 * (f - 32);
cout << "Celsius = " << c;
return 0;
}

#include<iostream>
using namespace std;
int main() {
float length, breadth, area;
cout << "Enter length and breadth: ";
cin >> length >> breadth;
area = length * breadth;
cout << "Area = " << area;
return 0;
}

#include<iostream>
using namespace std;
int main() {
int a, b, c, d;
cout << "Enter four integers: ";
cin >> a >> b >> c >> d;
cout << "Sum = " << (a+b+c+d) << endl;
cout << "Product = " << (a*b*c*d) << endl;
cout << "Average = " << (a+b+c+d)/4.0;
return 0;
}

#include<iostream>
using namespace std;
int main() {
float base, height, area;
cout << "Enter base and height: ";
cin >> base >> height;
area = 0.5 * base * height;
cout << "Area = " << area;
return 0;
}

You might also like