Computer StudyMCQ Computer ScienceQuiz Computer ScienceUGC NETUncategorized

C Programming Questions and Answers – Basics of Structures

C Programming Questions and Answers – Basics of Structures

1.Which of the following are themselves a collection of different data types?

a) string

b) structures

c) char

d) All of the mentioned

 

View Answer

 

Answer:b

2.User-defined data type can be derived by___________.

a) struct

b) enum

c) typedef

d) All of the mentioned

 

View Answer

 

Answer:d 

3.Which operator connects the structure name to its member name?

a) –

b) <-

c) .

d) Both (b) and (c)

 

View Answer

 

Answer:c

4.Which of the following cannot be a structure member?

a) Another structure

b) Function

c) Array

d) None of the mentioned

 

View Answer

 

Answer:b  

5.Which of the following structure declaration will throw an error?

a) struct temp{}s;

main(){}

b) struct temp{};

struct temp s;

main(){}

c) struct temp s;

struct temp{};

main(){}

d) None of the mentioned

 

View Answer

 

Answer:d  

6.What is the output of this C code?

 

#include <stdio.h>

struct student

{

int no;

char name[20];

}

void main()

{

struct student s;

s.no = 8;

printf(“hello”);

}

a) Compile time error

b) Nothing

c) hello

d) Varies

 

View Answer

 

Answer:a 

7.What is the output of this C code?

 

#include <stdio.h>

struct student

{

int no = 5;

char name[20];

};

void main()

{

struct student s;

s.no = 8;

printf(“hello”);

}

a) Nothing

b) Compile time error

c) hello

d) Varies

 

View Answer

 

Answer:b

8.What is the output of this C code?

 

#include <stdio.h>

struct student

{

int no;

char name[20];

};

void main()

{

student s;

s.no = 8;

printf(“hello”);

}

a) Nothing

b) hello

c) Compile time error

d) Varies

 

View Answer

 

Answer:c 

9.What is the output of this C code?

 

#include <stdio.h>

void main()

{

struct student

{

int no;

char name[20];

};

struct student s;

s.no = 8;

printf(“%d”, s.no);

}

a) Nothing

b) Compile time error

c) Junk

d) 8

 

View Answer

 

Answer:d  

10.Can the above code be compiled successfully?

 

#include <stdio.h>

struct p

{

int k;

char c;

float f;

};

int main()

{

struct p x = {.c = 97, .f = 3, .k = 1};

printf(“%f\n”, x.f);

}

a) Yes

b) No

c) Depends on the standard

d) Depends on the platform

 

View Answer

 

Answer:c

 

11.What is the output of this C code?

 

#include <stdio.h>

void main()

{

struct student

{

int no;

char name[20];

};

struct student s;

no = 8;

printf(“%d”, no);

}

a) Nothing

b) Compile time error

c) Junk

d) 8

 

View Answer

 

Answer:b 

12.Number of bytes in memory taken by the below structure is

 

#include <stdio.h>

struct test

{

int k;

char c;

};

a) Multiple of integer size

b) integer size+character size

c) Depends on the platform

d) Multiple of word size

 

View Answer

 

Answer:a 

13.What is the output of this C code?

 

#include <stdio.h>

struct

{

int k;

char c;

};

int main()

{

struct p;

p.k = 10;

printf(“%d\n”, p.k);

}

a) Compile time error

b) 10

c) Undefined behaviour

d) Segmentation fault

 

View Answer

 

Answer:a 

14.What is the output of this C code?

 

#include <stdio.h>

struct

{

int k;

char c;

} p;

int p = 10;

int main()

{

p.k = 10;

printf(“%d %d\n”, p.k, p);

}

a) Compile time error

b) 10 10

c) Depends on the standard

d) Depends on the compiler

 

View Answer

 

Answer:a 

15.What is the output of this C code?

 

#include <stdio.h>

struct p

{

int k;

char c;

};

int p = 10;

int main()

{

struct p x;

x.k = 10;

printf(“%d %d\n”, x.k, p);

}

a) Compile time error

b) 10 10

c) Depends on the standard

d) Depends on the compiler

 

View Answer

 

Answer:b  

16.What is the output of this C code?

 

#include <stdio.h>

struct p

{

int k;

char c;

float f;

};

int p = 10;

int main()

{

struct p x = {1, 97};

printf(“%f %d\n”, x.f, p);

}

a) Compile time error

b) 0.000000 10

c) Somegarbage value 10

d) 0 10

View Answer

 

Answer:b

17.What is the output of this C code(according to C99 standard)?

 

#include <stdio.h>

struct p

{

int k;

char c;

float f;

};

int main()

{

struct p x = {.c = 97, .f = 3, .k = 1};

printf(“%f\n”, x.f);

}

a) 3.000000

b) Compile time error

c) Undefined behaviour

d) 1.000000

View Answer

 

Answer:a 

18.What is the output of this C code(according to C99 standard)?

 

#include <stdio.h>

struct p

{

int k;

char c;

float f;

};

int main()

{

struct p x = {.c = 97, .k = 1, 3};

printf(“%f \n”, x.f);

}

a) 3.000000

b) 0.000000

c) Compile time error

d) Undefined behaviour

View Answer

 

Answer:b

19.What is the output of this C code(according to C99 standard)?

 

#include <stdio.h>

struct p

{

int k;

char c;

float f;

};

int main()

{

struct p x = {.c = 97};

printf(“%f\n”, x.f);

}

a) 0.000000

b) Somegarbagevalue

c) Compile time error

d) None of the mentioned

View Answer

 

Answer:a 

Related Articles

Leave a Reply

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

Back to top button