Data Types
- In C++, what is the sign of character data type by default?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
The standard does not specify if plain char is signed or unsigned. There are three distinct character types according to the standard: char, signed char and unsigned char.
- What will be the output of this program?
#include
using namespace std;
int main()
{
char ch = 65;
cout<< ch;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
The literal value for 65 is A. So it will be printing A.
- Select the right option.
Given the variables a, b are of char type and c, d, e are of int type
i. e = (c * d) / (c + d);
ii. e = (a * b) / (c + d);
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Every character constant has an integer value. Also char belongs to the integral type hence arithmetic and logical operations can be performed on them.
- Which of the following belongs to the set of character types?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
wchar_t and char is used to represent wide character and character.
- What is the output of the following program?
#include
using namespace std;
int main()
{
int a = -10;
unsigned int b = 20;
if(a > b)
{
cout << "a is greater";
}
else
{
cout << "b is greater";
}
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
a is promoted to unsigned int on comparison. On conversion a has all bits set, making it the bigger one.