LearnFrenzy
Sign in Take a free test

Typedef · Exercise 1 of 4

Typedef typedef MCQ

  • 12 questions
  • Page 1 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Twelve multiple-choice questions on typedef aliases, struct and function-pointer typedefs, typedef vs #define, const with pointer typedefs, scope and C23 typeof. Pick an option to check your answer instantly.

Question 1 Easy

What does typedef int Score; do?

A Creates a new type that cannot mix with int
B Creates the alias Score for int; Score and int are the same type
C Declares a variable named Score
D Defines a macro
Question page & discussion
Question 2 Hard

Which declaration is invalid?

A typedef unsigned int uint;
B typedef static int sint;
C typedef int Row[4];
D typedef int (*Fn)(void);
Question page & discussion
Question 3 Medium

Inside typedef struct node { … } Node;, how must the "next" pointer be declared?

A Node *next;
B struct node *next;
C node next;
D typedef Node *next;
Question page & discussion
Question 4 Hard

Given typedef char *String;, what is const String s;?

A const char *s – the characters are read-only
B char *const s – the pointer is read-only, the characters are not
C const char *const s
D It does not compile
Question page & discussion
Question 5 Medium

With #define PTR int *, what are a and b in PTR a, b;?

A Both int *
B a is int *, b is int
C Both int
D a is int, b is int *
Question page & discussion
Question 6 Medium

Which typedef defines Op as a pointer to a function taking two ints and returning an int?

A typedef int *Op(int, int);
B typedef int (*Op)(int, int);
C typedef (int *)Op(int, int);
D typedef int Op*(int, int);
Question page & discussion
Question 7 Medium

After typedef int Row[4];, what is the type of Row grid[3];?

A int[4][3]
B int[3][4] – 3 rows of 4 ints
C int[12]
D int *[3]
Question page & discussion
Question 8 Easy

Is a typedef inside a function body allowed?

A No, only at file scope
B Yes – it has block scope like a local variable
C Only with static
D Only in main()
Question page & discussion
Question 9 Medium

Why should your own typedefs avoid names like point_t?

A The compiler forbids them
B POSIX reserves the _t suffix for system types, so a future header may clash
C They are slower
D They cannot be used for structs
Question page & discussion
Question 10 Medium

With typedef int Meters; and typedef int Seconds;, what happens on Meters m = some_seconds;?

A A compile error
B It compiles silently – both are int, so typedef gives no type safety
C A warning about units
D A runtime conversion
Question page & discussion

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links