Consider the following C++ statement. Are they equivalent? char ch = 67; char ch = ‘C’;
Advertisements
Question
Consider the following C++ statement. Are they equivalent?
char ch = 67;
char ch = ‘C’;
Advertisements
Solution
Both the statements are equivalent as they declare ‘ch’ to be char and initialize it with the value of 67. Since this is the ASCII code for ‘C’, the character constant also can be used to initialize ‘ch’ to 67.
APPEARS IN
RELATED QUESTIONS
Which of the following is a valid string literal?
Which of the following is called compile-time operators?
What are keywords?
Assume n = 10; what will be result of n++ and --n;?
Match the following.
| A | B |
| (a) Modulus | (1) Tokens |
| (b) Separators | (2) Remainder of a division |
| (c) Stream extraction | (3) Punctuators |
| (d) Lexical Units | (4) get from |
Write about Binary operators used in C++.
What is the difference between 56L and 56?
Determine which of the following are valid constant? And specify their type.
0.5
What are arithmetic operators in C++? Differentiate unary and binary arithmetic operators. Give example for each of them.
How relational operators and logical operators are related to one another?
