IGDTUW 2026 Computer PYQ — What is the output of the following C++ program? #include <iostre… | Mathem Solvex | Mathem Solvex
Tip:A–D to answerE for explanationV for videoS to reveal answer
IGDTUW 2026 — Computer PYQ
IGDTUW | Computer | 2026
What is the output of the following C++ program?
#include <iostream>
using namespace std;
int main() {
char ch = 'A';
cout << int(ch);
return 0;
}
Choose the correct answer:
A.
A
B.
64
C.
65
(Correct Answer)
D.
66
Correct Answer:
65
Explanation
Step-by-Step Explanation:
Character Initialization:
The variable ch is declared as a char type and initialized with the character literal 'A'.
char ch=’A’;
ASCII Representation:
In C++, characters are internally stored as their corresponding integer values based on the ASCII (American Standard Code for Information Interchange) standard. The ASCII value for the uppercase character 'A' is exactly:
65
Explicit Type Casting:
The expression int(ch) explicitly converts (type-casts) the variable ch from a char type to an int type.
Output Generation:
When a char is passed to cout, it prints the visual character representation (A). However, because it has been explicitly cast to an int, cout treats it as a numeric integer value and prints its decimal code directly. Therefore, the program prints:
65
Explanation
Step-by-Step Explanation:
Character Initialization:
The variable ch is declared as a char type and initialized with the character literal 'A'.
char ch=’A’;
ASCII Representation:
In C++, characters are internally stored as their corresponding integer values based on the ASCII (American Standard Code for Information Interchange) standard. The ASCII value for the uppercase character 'A' is exactly:
65
Explicit Type Casting:
The expression int(ch) explicitly converts (type-casts) the variable ch from a char type to an int type.
Output Generation:
When a char is passed to cout, it prints the visual character representation (A). However, because it has been explicitly cast to an int, cout treats it as a numeric integer value and prints its decimal code directly. Therefore, the program prints: