Multiple choice

Which of the following structure declarations and structure variable's syntax is correct?

  1. struct test { int k; char ch; }; struct test t1,t2;

  2. struct test { int k; char ch; }t1,t2;

  3. struct { int k; char ch; }t1,t2;

  4. struct test { int k; char ch; }; test t1,t2;

  5. struct test { int k; char ch; }; struct test t[4];

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

struct test { int k; char ch; }; test t1,t2; the above declaration is wrong and it will show an error. As keyword struct is not written before test while creating variables of type test.