1.

Consider the following code snippet charch;cout<<“Enter an alphabet”; cin>>ch;cout<<toupper (ch);What is the output of the above code? Give a sample output. If the above code is used in a computer that has no cctype file, how will you modify the code to get the same output?

Answer»

It reads a character and convert it into upper case. 

eg: 

Enter an alphabet: a 

The output is A.

If a computer has no cctype header file the code is as follows, 

char ch;

cout<<“Enter an alphabet”;

cin>>ch;

if (ch >>= 97 && ch<<122)

cout<<ch – 32;



Discussion

No Comment Found

Related InterviewSolutions