0% found this document useful (0 votes)
4 views

programming in c quiz

The document consists of a series of multiple-choice questions related to the C programming language, covering topics such as variable naming, keywords, data types, and output of code snippets. Each question includes options and the correct answer is provided. The questions test knowledge on C syntax, data structures, and compiler behavior.

Uploaded by

selvapriyakskcet
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

programming in c quiz

The document consists of a series of multiple-choice questions related to the C programming language, covering topics such as variable naming, keywords, data types, and output of code snippets. Each question includes options and the correct answer is provided. The questions test knowledge on C syntax, data structures, and compiler behavior.

Uploaded by

selvapriyakskcet
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1. Which of the following cannot be a variable name in C?

a) volatile
b) true
c) friend
d) export
Answer : a)
2. Which keyword is used to prevent any changes in the variable within a C program?
a) immutable
b) mutable
c) const
d) volatile
Answer : c)
3. The C-preprocessors are specified with _________ symbol.
a) #
b) $
c) ” ”
d) &
Answer:a)
4. In C language, FILE is of which data type?
a) int
b) char *
c) struct
d) None of the mentioned
Answer : c)
5. What is the sizeof(char) in a 32-bit C compiler?
a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes
Answer : c)
6. What will be the output of the following C code on a 64 bit machine?
1. #include <stdio.h>
2. union Sti
3. {
4. int nu;
5. char m;
6. };
7. int main()
8. {
9. union Sti s;
10. printf("%d", sizeof(s));
11. return 0;
12. }
a) 8
b) 5
c) 9
d) 4
Answer: d
Explanation: Since the size of a union is the size of its maximum data type, here int
is the largest data type. Hence the size of the union is 4.
Output:
$ cc pgm7.c
$ a.out
4
7. What will be the final value of x in the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int x = 5 * 9 / 3 + 9;
5. }

a) 3.75
b) Depends on compiler
c) 24
d) 3

Answer: c
8. Comment on the following C statement.

n = 1;
printf("%d, %dn", 3*n, n++);

a) Output will be 3, 2
b) Output will be 3, 1
c) Output will be 6, 1
d) Output is compiler dependent

Answer: d

9. What will be the data type returned for the following C function?
1. #include <stdio.h>
2. int func()
3. {
4. return (double)(char)5.0;
5. }

a) char
b) int
c) double
d) multiple type-casting in return is illegal

Answer: b
10. Which option should be selected to work the following C expression?

string p = "HELLO";

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

You might also like