250+ TOP MCQs on Typedefs and Answers

C helps anyone preparing for Sony and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear Sony interviews on C Programming language.

Here is a listing of C Objective Questions on “Typedefs” along with answers, explanations and/or solutions:

1. Which is the correct syntax to use typedef for struct?
a)

    typedef struct temp
    {
        int a;
    }TEMP;

b)

    typedef struct
    {
        int a;
     }TEMP;

c)

    struct temp
    {
        int a;
    };
    typedef struct temp TEMP;

d) All of the mentioned
Answer: d
Clarification: None.

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

a) typedef char [] string;
b) typedef char *string;
c) typedef char [] string; and typedef char *string;
d) Such expression cannot be generated in C
Answer: b
Clarification: None.

3. Which of the given option is the correct method for initialization?

a) *string *p = “Hello”;
b) string p = “Hello”;
c) *string p = ‘A’;
d) Not more than one space should be given when using typedef
Answer: b
Clarification: None.

4. Which of the following is false about typedef?
a) typedef follow scope rules
b) typedef defined substitutes can be redefined again. (Eg: typedef char a; typedef int a;)
c) You cannot typedef a typedef with other term
d) All of the mentioned
Answer: b
Clarification: None.

5. Which of the following may create problem in the typedef program?
a) ;
b) printf/scanf
c) Arithmetic operators
d) All of the mentioned
Answer: d
Clarification: None.

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

Answer: a
Clarification: None.

7. What is typedef declaration?
a) Does not create a new type
b) It merely adds a new name for some existing type
c) Does not create a new type, It merely adds a new name for some existing type
d) None of the mentioned
Answer: c
Clarification: None.

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

  1.     #include 
  2.     typedef struct student
  3.     {
  4.         char *a;
  5.     }stu;
  6.     void main()
  7.     {
  8.         stu s;
  9.         s.a = "hi";
  10.         printf("%s", s.a);
  11.     }s

a) Compile time error
b) Varies
c) hi
d) h
Answer: a
Clarification: None.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top