Typedef MCQ Questions & Answers

This section focuses on the "typedef" in C programming. These Multiple Choice Questions (MCQ) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. The C programming language provides a keyword called _________, which you can use to give a type a new name.

A. type
B. typedef
C. typed
D. tpdef

View Answer


2. can we use typedef to give a name to your user defined data types as well?

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer


3. ___________ is a C-directive which is also used to define the aliases for various data types.

A. #const
B. #def
C. #define
D. #dir

View Answer


4. __________ statements are processed by the pre-processor.

A. #def
B. typedef
C. type
D. #define

View Answer


5. What will be output for the following code?

#include <stdio.h>
#define TRUE  1
 
int main( ) {
   printf( ""Value of TRUE : %d
"", TRUE);
   return 0;
}

A. 0
B. 1
C. null
D. garbage

View Answer


6. Which option should be selected to work the following C expression?

string p = "HELLO";

A. typedef char [] string;
B. typedef char [] string; and typedef char *string;
C. typedef char *string;
D. Such expression cannot be generated in C

View Answer


7. typedef int (*PFI)(char *, char *)creates ___________

A. type PFI, for pointer to function (of two char * arguments) returning int
B. error
C. type PFI, function (of two char * arguments) returning int
D. type PFI, for pointer

View Answer


8. What will be the output of the following C code?

#include <stdio.h>
typedef struct student
    {
        char *a;
    }stu;
    void main()
    {
        struct stu s;
        s.a = ""hi"";
        printf(""%s"", s.a);
    }

A. hi
B. h
C. Compile time error
D. varies

View Answer


9. What will be the output of the following C code?

#include <stdio.h>
typedef struct student
    {
        char *a;
    }stu;
    void main()
    {
        struct student s;
        s.a = ""hey"";
        printf(""%s"", s.a);
    }

A. Compile time error
B. varies
C. he
D. hey

View Answer


10. #define can be used to define alias for values as well

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer






Discussion



* You must be logged in to add comment.