Class 11
Computer Science
Ch 1: Programming in C++
C++ Lab Problems & Viva-Voce Master Guide
Class 11 Practical Exam C++ Problem Set
Problem 1: Check Palindrome Number
#include <iostream.h>
int main() {
int n, num, digit, rev = 0;
cout << "Enter any positive integer: ";
cin >> num;
n = num;
while (num != 0) {
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
}
if (n == rev)
cout << n << " is a Palindrome Number." << endl;
else
cout << n << " is NOT a Palindrome Number." << endl;
return 0;
}
Class 11 C++ Viva-Voce Questions:
Q1: What is the difference between
= and == in C++?
Ans: = is the assignment operator (assigns value on right to variable on left), whereas == is the relational equality comparison operator.
Q2: What is the purpose of the
endl manipulator?
Ans: It inserts a new line character in the output stream and flushes the buffer.
Practice Questions (1)
View All Chapter Q&AMultiple Choice Questions (1)
MCQ 1
+1.00 Mark
In C++, which header file must be included to use the setw() stream manipulator?
A
stdio.h
B
iostream.h
C
iomanip.h
D
conio.h
Correct:
Option C: iomanip.h
Explanation:
setw() is a stream manipulator declared in <iomanip.h> used for formatted field width specification.