![CProgramming Tutorial](/cprogramming/images/c-mini-logo.jpg)
- C Programming Tutorial
- C - Home
- Basics of C
- 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 - Type Conversion
- C - Type Casting
- C - Booleans
- Constants and Literals in C
- C - Constants
- C - Literals
- C - Escape sequences
- C - Format Specifiers
- Operators in C
- C - Operators
- C - Arithmetic Operators
- C - Relational Operators
- C - Logical Operators
- C - Bitwise Operators
- C - Assignment Operators
- C - Unary Operators
- C - Increment and Decrement Operators
- C - Ternary Operator
- C - sizeof Operator
- C - Operator Precedence
- C - Misc Operators
- Decision Making in C
- C - Decision Making
- C - if statement
- C - if...else statement
- C - nested if statements
- C - switch statement
- C - nested switch statements
- Loops in C
- 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
- Functions in C
- C - Functions
- C - Main Function
- C - Function call by Value
- C - Function call by reference
- C - Nested Functions
- C - Variadic Functions
- C - User-Defined Functions
- C - Callback Function
- C - Return Statement
- C - Recursion
- Scope Rules in C
- C - Scope Rules
- C - Static Variables
- C - Global Variables
- Arrays in C
- C - Arrays
- C - Properties of Array
- C - Multi-Dimensional Arrays
- C - Passing Arrays to Function
- C - Return Array from Function
- C - Variable Length Arrays
- Pointers in C
- C - Pointers
- C - Pointers and Arrays
- C - Applications of Pointers
- C - Pointer Arithmetics
- C - Array of Pointers
- C - Pointer to Pointer
- C - Passing Pointers to Functions
- C - Return Pointer from Functions
- C - Function Pointers
- C - Pointer to an Array
- C - Pointers to Structures
- C - Chain of Pointers
- C - Pointer vs Array
- C - Character Pointers and Functions
- C - NULL Pointer
- C - void Pointer
- C - Dangling Pointers
- C - Dereference Pointer
- C - Near, Far and Huge Pointers
- C - Initialization of Pointer Arrays
- C - Pointers vs. Multi-dimensional Arrays
- Strings in C
- C - Strings
- C - Array of Strings
- C - Special Characters
- C Structures and Unions
- C - Structures
- C - Structures and Functions
- C - Arrays of Structures
- C - Self-Referential Structures
- C - Lookup Tables
- C - Dot (.) Operator
- C - Enumeration (or enum)
- C - Structure Padding and Packing
- C - Nested Structures
- C - Anonymous Structure and Union
- C - Unions
- C - Bit Fields
- C - Typedef
- File Handling in C
- C - Input & Output
- C - File I/O (File Handling)
- C Preprocessors
- C - Preprocessors
- C - Pragmas
- C - Preprocessor Operators
- C - Macros
- C - Header Files
- Memory Management in C
- C - Memory Management
- C - Memory Address
- C - Storage Classes
- Miscellaneous Topics
- C - Error Handling
- C - Variable Arguments
- C - Command Execution
- C - Math Functions
- C - Static Keyword
- C - Random Number Generation
- C - Command Line Arguments
- C Programming Resources
- C - Questions & Answers
- C - Quick Guide
- C - Cheat Sheet
- 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.
![Questions and Answers](/images/questions_and_answers.png)
Q 1 - What is the output of the following code snippet?
#include<stdio.h> main() { char c = 'A'+255; printf("%c", c); }
Answer : A
Explanation
A, the range of ASCII values for the ASCII characters is 0-255. Hence the addition operation circulates back to ‘A’
Q 2 - What is the output of the following program?
#include<stdio.h> { int x = 1; switch(x) { default: printf("Hello"); case 1: printf("hi"); break; } }
Answer : B
Explanation
Hi, control reaches default-case after comparing the rest of case constants.
Answer : B
Explanation
volatile is the reserved keyword and cannot be used an identifier name.
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 statement?
#include<stdio.h> main() { printf("%d", -1<<1 ); }
Answer : B
Explanation
A negative number stored in two’s compliment of positive number. After shifting we get 1110, which is equivalent to -2.
Q 6 - A Variable name in C includes which special symbols?
Answer : D
Explanation
Characters which are allowed and not allowed with variable name,
- Underscore(_) allowed
- Capital Letters ( A – Z ) allowed
- Small Letters ( a – z ) allowed
- Digits ( 0 – 9 ) allowed
- First Character should be alphabet or Underscore
- Blanks & Commas not allowed
- Special Symbols not allowed, but Underscore(_)allowed
- Reserved Word not allowed
Q 7 - The correct order of mathematical operators in mathematics and computer programming,
A - Addition, Subtraction, Multiplication, Division
B - Division, Multiplication, Addition, Subtraction
Answer : B
Explanation
It is BODMAS.
Q 8 - Which scanf() statement will you use to scan a float value (a) and double value (b)?
Float a; Double b;
Answer : D
Explanation
In C Programming, the scanf() can be used to read a formatted string from the stdin stream, where as; scanf() uses %lf to read a double value and %f to read a floating-point number in fixed decimal format.
int scanf(const char *format, ...)
Q 9 - During preprocessing, the code “#include<stdio.h>” gets replaced by the contents of the file stdio.h.
B - During linking the code “#include<stdio.h>” replaces by stdio.h
C - During execution the code “#include<stdio.h>” replaces by stdio.h
D - During editing the code “#include<stdio.h>” replaces by stdio.h
Answer : A
Explanation
Preprocessing enlarges and boosts the C programming language by replacing preprocessing directive “#include<stdio.h>” with the content of the file stdio.h.
Q 10 - The library function strrchr() finds the first occurrence of a substring in another string.
Answer : B
Explanation
Strstr() finds the first occurrence of a substring in another string.