C Structure, Union, Enums Test 26) What will be the output of the below program?
The correct option is (c). Explanation: In a program system will allocate 2 bytes for the union. The statements un.ch[0]=3; un.ch[1]=2; store the data in memory. Therefore the output of program is 3, 2, 515. 7) What will be the output of the below program?
The correct option is (d). Explanation: Increment and decrement operations are not allowed to be performed in user defined data type. Since enum is a user defined data type, no operations can be performed on user-defined data types. Therefore ++ or -- logical operations cannot be done on enum value and the program will return compile error in the output on using this operations in enum data type. 8) Find out the error in the below program?
The correct option is (b). Explanation: The structure employ contains a member 'e' of a same data type i.e. struct employ. In this stage the compiler does not know the size of structure. Therefore the compiler returns Error: in structure declaration. 9) Find out the error in the below program?
The correct option is (c). Explanation: In program we assign string to a struct variable like e.name = "Nakul"; In C programming language we are not allowed to assign a string to struct variable. We have to use strcpy(char *dest, const char *source) function for assigning a string For example: strcpy(e.name, "Nakul"); Therefore the compiler returns Error: Lvalue required/incompatible types in assignment 10) What will be the output of the below program?
The correct option is (c). Explanation: In enum data type sequence always start with 0. If the value is assigned then sequence continues from the assigned value. Therefore 0 8 is the output of the given program. Next TopicC Structure, Union, Enums 3 |