C- Typedef Questions and Answers

C- Typedef

Showing 10 of 23 questions
1. In the following code, the P2 is Integer Pointer or Integer? typedef int *ptr; ptr p1, p2;
  • Integer
  • Integer pointer
  • Error in declaration
  • None of above
Show Answer Report
2. In the following code what is 'P'? typedef char *charp; const charp P;
  • P is a constant
  • P is a character constant
  • P is character type
  • None of above
Show Answer Report
3. What is x in the following program? #include<stdio.h> int main() {     typedef char (*(*arrfptr[3])())[10];     arrfptr x;     return 0; }
  • x is a pointer
  • x is an array of three pointer
  • x is an array of three function pointers
  • Error in x declaration
Show Answer Report
4. What is the primary purpose of typedef in C?
  • To create new data types
  • To create alias names for existing types
  • To define constants
  • To allocate memory
Show Answer Report
5. Which of the following is the correct syntax for typedef?
  • typedef new_name existing_type;
  • existing_type typedef new_name;
  • typedef existing_type new_name;
  • new_name typedef existing_type;
Show Answer Report
6. What does typedef do with structures?
  • Allocates memory for structure
  • Creates shorter names for structures
  • Initializes structure members
  • Defines structure size
Show Answer Report
7. Which statement about typedef is FALSE?
  • Creates type aliases
  • Can be used with structures
  • Can be used with pointers
  • Creates new memory locations
Show Answer Report
8. How to declare a typedef for an integer pointer?
  • typedef int_ptr int*;
  • typedef int* int_ptr;
  • typedef *int int_ptr;
  • typedef int int_ptr*;
Show Answer Report
9. What is the advantage of using typedef with function pointers?
  • Reduces code size
  • Increases execution speed
  • Makes code more readable
  • Automatically initializes pointers
Show Answer Report
10. Can typedef be used with arrays?
  • No, arrays cannot be typedefed
  • Yes, but only 1D arrays
  • Yes, arrays can be typedefed
  • Only with constant size
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test