• C Programming Video Tutorials

C Programming - Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers
cprogramming_questions_answers.htm

Q 1 - What is the output of the following code snippet?

#include<stdio.h>

main()
{ 
   int *p = 15; 
   printf("%d",*p);
}

A - 15

B - Garbage value

C - Runtime error

D - Compiler error

Answer : C

Explanation

Runtime error, as the pointer variable is not holding proper address, writing/reading the data from the same raises runtime error.

Q 2 - The type name/reserved word ‘short’ is ___

A - short long

B - short char

C - short float

D - short int

Answer : D

Explanation

short is used as an alternative of short int.

Q 3 - What is the output of the following program?

#include<stdio.h>

main()
{	
   union abc {
      int x;
      char ch;
   }var;

   var.ch = 'A';
   printf("%d", var.x);
}

A - A

B - Garbage value

C - 65

D - 97

Answer : C

Explanation

65, as the union variables share common memory for all its elements, x gets ‘A’ whose ASCII value is 65 and is printed.

Q 4 - What is the output of the following program?

#include<stdio.h>

main()
{	
   int a[] = {10, 20, 30};
   
   printf("%d", *a+1);
}

A - 10

B - 20

C - 11

D - 21

Answer : C

Explanation

*a refers to 10 and adding a 1 to it gives 11.

Q 5 - Which of the following functions disconnects the stream from the file pointer.

A - fremove()

B - fclose()

C - remove()

D - file pointer to be set to NULL

Answer : B

Explanation

fclose(), it flushes the buffers associated with the stream and disconnects the stream with the file.

Q 6 - In C programming language, a function prototype is a declaration of the function that just specifies the function’s interface (function's name, argument types and return type) and extracts the body of the function. By defining the function, we get to know what action a particular function is going to perform.

A - True

B - False

Answer : A

Explanation

Explanation: The function body shall associate a specific task, hence representing the action.

Q 8 - Which of the following statement can be used to free the allocated memory?

A - remove(var-name);

B - free(var-name);

C - vanish(var-name);

D - erase(var-name);

Answer : B

Explanation

The library function free() deallocates the memory allocated by calloc(), malloc(), or realloc().

Answer : A

Explanation

Unary operator acts on single expression.

Q 10 - The maximum combined length of the command-line arguments as well as the spaces between adjacent arguments is – a) 120 characters, b) 56 characters, c) Vary from one OS to another

A - a

B - a, b

C - a, b, c

D - c

Answer : D

Explanation

The maximum combined length of the command-line arguments and the spaces between adjacent arguments vary from one OS to another.

Advertisements