- C Programming Tutorial
- C - Home
- C - Overview
- C - Features
- C - History
- C - Environment Setup
- C - Program Structure
- C - Hello World
- C - Compilation Process
- C - Comments
- C - Tokens
- C - Keywords
- C - Identifiers
- C - User Input
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Integer Promotions
- C - Constants
- C - Literals
- C - Escape sequences
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - if statement
- C - if...else statement
- C - nested if statements
- C - switch statement
- C - nested switch statements
- C - Loops
- C - While loop
- C - For loop
- C - Do...while loop
- C - Nested loop
- C - Infinite loop
- C - Break Statement
- C - Continue Statement
- C - goto Statement
- C - Functions
- C - Main Functions
- C - Return Statement
- C - Recursion
- C - Scope Rules
- C - Arrays
- C - Properties of Array
- C - Multi-Dimensional Arrays
- C - Passing Arrays to Function
- C - Return Array from Function
- C - Variable Length Arrays
- C - Pointers
- C - Pointer Arithmetics
- C - Passing Pointers to Functions
- C - Strings
- C - Array of Strings
- C - Structures
- C - Structures and Functions
- C - Arrays of Structures
- C - Pointers to Structures
- C - Self-Referential Structures
- C - Nested Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
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.
Q 1 - What is the output of the below code snippet?
#include<stdio.h> main() { for()printf("Hello"); }
Answer : D
Explanation
Compiler error, semi colons need to appear though the expressions are optional for the ‘for’ loop.
Q 2 - What is the output of the following program?
#include<stdio.h> main() { int x = 65, *p = &x; void *q=p; char *r=q; printf("%c",*r); }
Answer : B
Explanation
A, void pointer is a generic pointer and can hold any variable’s address. ASCII character for the value 65 is ‘A’
Q 3 - Following is the invalid inclusion of a file to the current program. Identify it.
Answer : C
Explanation
option (a) & (b) are valid. There is no such syntax or provision as in option (c).
Q 4 - What is the output of the following program?
#include<stdio.h> main() { char *p = NULL; printf("%c", *p); }
Answer : D
Explanation
It is invalid to access the NULL address hence giving run time error.
Q 5 - What is the output of the following program?
#include<stdio.h> main() { char *s = "Hello"; while(*s!=NULL) printf("%c", *s++); }
Answer : A
Explanation
NULL is equivalent to ‘\0’ in value. Statement *s++ prints the character first and increments the address later.
Q 6 - The C library function rewind() reposition the file pointer at the beginning of the file.
Answer : A
Explanation
void rewind(FILE *stream): In C, the rewind function reposition the file position to the beginning of the file of the given stream. It also erases the error and end-of-file indicators for stream.
Answer : A
Explanation
Logical NOT operator will make false.
Q 8 - The return keyword used to transfer control from a function back to the calling function.
Answer : A
Explanation
In C, the return function stops the execution of a function and returns control with value to the calling function. Execution begins in the calling function by instantly following the call.
Q 9 - Which printf() statement will you use to print out a (float value) and b (double value)?
Float a = 3.14; Double b = 3.14;
Answer : A
Explanation
%f can be use to print out float value and %lf can be use to print out double value.
Q 10 - extern int fun(); - The declaration indicates the presence of a global function defined outside the current module or in another file.
Answer : A
Explanation
Extern is used to resolve the scope of global identifier.