![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 Functions
- 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 - 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)
Answer : D
Explanation
-2, the one’s compliment of 1 is 1110 (binary) which is equivalent to two’s compliment of 2, ie -2.
Q 2 - The type name/reserved word ‘short’ is ___
Answer : D
Explanation
short is used as an alternative of short int.
Q 3 - Compiler generates ___ file.
Answer : B
Explanation
(b). Compilation is the process of translating high level language statements into equivalent machine code, which is object code.
Q 4 - Does both the loops in the following programs prints the correct string length?
#include<stdio.h> main() { int i; char s[] = "hello"; for(i=0; s[i]; ++i); printf("%d ", i); i=0; while(s[i++]); printf("%d ", i); }
A - Yes, both the loops prints the correct length
B - Only for loop prints the correct length
Answer : B
Explanation
In while loop ‘i’ gets incremented after checking for ‘\0’, hence giving 1 more than the length.
Q 5 - Which of the following functions disconnects the stream from the file pointer.
Answer : B
Explanation
fclose(), it flushes the buffers associated with the stream and disconnects the stream with the file.
Q 6 - Turbo C in 16 bit DOS OS, the correct range of “long double” is,
Answer : B
Explanation
Explanation: The integral and precession value varies depending upon the number of bytes designated for a particular data type.
Q 7 - Which library function can convert an integer/long to a string?
Answer : A
Explanation
In C, ltoa() function converts long/integer data type to string data type.
char *ltoa(long N, char *str, int base);
Q 8 - In DOS, What is the purpose of the function randomize() in Turbo C?
A - Displays a random number generator with a random value based on time
C - Displays a random number generator in the specified range.
Answer : A
Explanation
randomize() picks the current time value as the SEED number to generate random numbers.
Q 9 - The correct order of evaluation for the expression “z = x + y * z / 4 % 2 – 1”
Answer : D
Explanation
* / % holds highest priority than + - . All with left to right associativity.
Q 10 - According to ANSI specification, how to declare main () function with command-line arguments?
A - int main(int argc, char *argv[])
B - int char main(int argc, *argv)
Answer : A
Explanation
Some time, it becomes necessary to deliver command line values to the C programming to execute the particular code when the code of the program is controlled from outside. Those command line values are called command line arguments. The command line arguments are handled by the main() function.
Declaration of main () with command-line argument is,
int main(int argc, char *argv[])
Where, argc refers to the number of arguments passed, and argv[] is a pointer array which points to each argument passed to the program.
To Continue Learning Please Login