Data Types


  1. Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char) return?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The standard does NOT require a char to be 8-bits, but does require that sizeof(char) return 1.


  1. In C++, what is the sign of character data type by default?











  1. 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.



  1. Is the size of character literals different in C and C++?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    In C++, sizeof(‘a’) == sizeof(char) == 1. In C however, sizeof(‘a’) == sizeof(int).


  1. What is the output of this program?
    #include 
    using namespace std;
    int main()
    {
    char ch = 'M';

    cout<< ch;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    M



  1. What constant defined in header returns the number of bits in a char?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    CHAR_BIT