Unlock hundreds more features
Save your Quiz to the Dashboard
View and Export Results
Use AI to Create Quizzes and Analyse Results

Sign inSign in with Facebook
Sign inSign in with Google

C Quiz Practice: Test Your Knowledge

Enhance skills with interactive exam practice questions

Difficulty: Moderate
Grade: Grade 11
Study OutcomesCheat Sheet
Paper art depicting trivia for The C Quiz Challenge, a tool testing C programming knowledge.

Which of the following is the correct syntax for including the standard input/output library in C?
#include
include
#import
using namespace std;
The correct way to include the standard I/O library in C is by using the #include directive with angle brackets. This tells the preprocessor to include the header file 'stdio.h' in the program.
What is the correct way to declare an integer variable named 'count' in C?
int count;
integer count;
var count = 0;
int:count;
In C, variables are declared by specifying the data type followed by the variable name. The declaration 'int count;' correctly defines a variable named count as an integer.
Which symbol is used to terminate a statement in C?
;
.
,
:
A semicolon (;) is used to end a statement in C, marking the end of an executable instruction. This is a fundamental part of the C programming syntax.
Which of these is a valid identifier in C?
myVar1
1stVar
my-var
my var
Identifiers in C must begin with a letter or an underscore and can contain letters and digits thereafter. 'myVar1' follows these rules, making it a valid identifier, whereas the other options break one or more C naming conventions.
How do you write a single-line comment in C?
// This is a comment
/* This is a comment */
# This is a comment
-- This is a comment
Single-line comments in C are written using // at the beginning of the comment. While /* */ can also denote comments, they are generally used for multi-line comments.
What is the output of the expression 5 / 2 in C when using integer division?
2
2.5
3
2.0
In C, when both operands are integers, the division operator performs integer division. This means the result is truncated to an integer, so 5 / 2 equals 2.
Which of the following best describes a function prototype in C?
It declares the function's name, return type, and parameters without providing the function's body.
It defines the function's body with all executable code.
It lists only the function's parameters.
It comments out the function details for documentation purposes.
A function prototype in C provides the compiler with the function's signature including its return type and parameter types, without containing the actual implementation. This enables type checking during compilation and facilitates separate compilation.
In C, which operator is used to access the value at a pointer's address?
*
&
->
%
The asterisk (*) operator is used in C to dereference a pointer, which means accessing the value stored at the memory address the pointer holds. The & operator, conversely, is used to obtain the address of a variable.
What is the purpose of the 'return' statement in a C function?
To end the function execution and optionally return a value to the calling function.
To declare a variable as global.
To loop back to the beginning of the function.
To import expressions from another module.
The 'return' statement terminates the execution of a function and may send a value back to the function caller. It is essential for controlling the flow of data between functions in C.
Which of the following is the correct declaration of a function 'add' that takes two integers as parameters and returns an integer?
int add(int, int);
add(int a, int b): int;
int add(int a, int b) { }
function int add(int, int);
The declaration 'int add(int, int);' correctly specifies the return type and parameter types without including the function body. It is a proper function prototype which informs the compiler about the function signature.
How does a 'for' loop differ from a 'while' loop in C?
A 'for' loop includes initialization, condition, and update in one line, whereas a 'while' loop only includes a condition.
A 'for' loop checks the condition after executing the loop body, and a 'while' loop checks it before.
A 'for' loop is used only with arrays, while a 'while' loop is used for pointers.
There is no difference; both loops function identically.
A 'for' loop in C is designed to include initialization, test condition, and iteration expression all in one line, offering a compact loop structure. A 'while' loop, on the other hand, only specifies a condition and requires separate statements for initialization and update.
What does the modulus operator (%) do in C?
It returns the remainder of the division of two integers.
It calculates the percentage of a number.
It divides two numbers and returns a floating-point result.
It multiplies two numbers and returns the modulus.
The modulus operator (%) gives the remainder after an integer division, which is useful in scenarios like determining even or odd numbers. It does not perform any percentage calculations or multiply values.
Which keyword is used to define a constant value in C that cannot be altered?
const
final
static
immutable
The 'const' keyword in C is used to declare variables whose values should not change after initialization. Other keywords listed do not provide the same guarantee in C.
In C, which of the following statements about arrays is correct?
All elements in an array are stored in contiguous memory locations.
Arrays can store elements of different data types in a single array declaration.
The size of an array can be changed dynamically once declared.
Array indexes in C start at 1 instead of 0.
Arrays in C are stored in contiguous blocks of memory, which is why pointer arithmetic works efficiently with them. The notions of dynamic resizing and mixed data types in arrays are not permitted in standard C arrays.
What happens when you attempt to access an array index that is out of bounds in C?
The behavior is undefined, possibly leading to a program crash.
The program will automatically resize the array.
The compiler will throw a runtime error.
C fills the missing array values with zero.
Accessing an array outside its defined limits leads to undefined behavior in C. This can result in unexpected results or program crashes since no bounds checking is performed by the language.
In C, what does the following code snippet output? #include int main() { int i = 3; printf("%d", i++ + ++i); return 0; }
Undefined behavior
7
8
6
The expression 'i++ + ++i' modifies the variable 'i' more than once without an intervening sequence point, leading to undefined behavior. This means the program's output cannot be relied upon to be consistent across different compilers.
Which of the following correctly allocates memory dynamically for an array of 10 integers in C?
int* arr = (int*)malloc(10 * sizeof(int));
int arr = malloc(10 * sizeof(int));
int arr[10] = malloc(sizeof(int));
int* arr = malloc(10);
The correct method for allocating memory for an array of 10 integers is to multiply 10 by the size of an int and cast the returned pointer from malloc. This ensures that sufficient memory is allocated and that the pointer type is correct.
In C, what is the effect of declaring a variable as 'static' inside a function?
The variable retains its value between function calls.
The variable becomes globally accessible in the entire program.
The variable is re-initialized each time the function is called.
The variable is only allocated on the stack for one function call.
Declaring a variable as static inside a function causes it to retain its value between multiple calls to that function. This means the variable is initialized only once and maintains its state throughout the program execution.
Which function header is used by the standard C library to read formatted input from the console?
scanf()
gets()
printf()
fgets()
The function scanf() is used to read formatted input from the console, making it suited for capturing various data types according to a specified format. The other functions serve different purposes, such as output or unformatted input.
What is the primary purpose of header files in a C program?
To declare function prototypes and macros that can be shared across multiple files.
To execute the program's main logic.
To allocate memory dynamically during runtime.
To define the main function.
Header files in C are used to declare interfaces such as function prototypes, macros, and type definitions. They promote modularity and code reuse by allowing multiple source files to share common declarations.
0
{"name":"Which of the following is the correct syntax for including the standard input\/output library in C?", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Which of the following is the correct syntax for including the standard input\/output library in C?, What is the correct way to declare an integer variable named 'count' in C?, Which symbol is used to terminate a statement in C?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}

Study Outcomes

  1. Understand fundamental C programming syntax and structure.
  2. Analyze variable declarations and data types in C.
  3. Apply control flow constructs such as loops and conditionals.
  4. Evaluate and debug simple C programs for logic errors.
  5. Implement basic input/output operations in C.

C Quiz: Practice Test & Review Cheat Sheet

  1. Basic C Program Structure - Dive into the blueprint of every C application by understanding how #include directives fetch essential libraries and how the main() function acts as your program's launchpad. Getting comfortable with this skeleton ensures you can write, read, and troubleshoot C code like a seasoned developer. GeeksforGeeks C Programming Language
  2. Data Types in C - Unlock the secrets of int, float, char, and double by comparing their sizes, ranges, and ideal use cases. Choosing the right type helps supercharge your program's performance and avoids those pesky overflow bugs. Upskill Campus C Programming Tutorial
  3. Variables & Constants - Get hands‑on with naming, declaring, and initializing your data holders. Remember: variable names must start with a letter or underscore and can't collide with reserved keywords, while constants keep values locked and safe throughout your code. Upskill Campus C Programming Tutorial
  4. Operators Galore - From arithmetic heroes like + and * to relational warriors == and <, plus logical sidekicks && and ||, operators are your decision‑making toolbox. Master these to perform math, compare values, and craft branching logic that drives your program forward. GeeksforGeeks C Programming Language
  5. Control Flow Fundamentals - Command the flow of your program with if, else, and switch statements, plus loop structures like for, while, and do-while. These constructs let you repeat tasks and make decisions, turning static code into dynamic logic. GeeksforGeeks 20-Day C Curriculum
  6. Functions & Prototypes - Break your code into bite‑sized pieces by defining custom functions and declaring prototypes before use. This not only keeps your files neat but also promotes reusability - so you can call the same code snippet again and again without rewriting it. GeeksforGeeks C Programming Language
  7. Arrays & Strings - Learn how to store collections of items with arrays and manipulate text with strings (character arrays terminated by '\0'). These powerful data structures let you loop through lists or process words, sentences, and more with ease. GeeksforGeeks 20-Day C Curriculum
  8. Pointers & Memory Addresses - Become a memory maestro by mastering pointers, pointer arithmetic, and their link to arrays. With pointers you can unlock direct access to variable addresses, enabling efficient data manipulation and dynamic data structures. GeeksforGeeks C Programming Language
  9. Dynamic Memory Allocation - Find out when and how to grab extra memory on the fly using malloc(), calloc(), realloc(), and free(). Proper memory management ensures your programs run smoothly without leaks or crashes. GeeksforGeeks 20-Day C Curriculum
  10. File Handling Essentials - Empower your programs to read from and write to files with fopen(), fclose(), fprintf(), and fscanf(). Whether you're logging data or loading configuration files, file I/O opens up a world of persistent storage. GeeksforGeeks C Programming Language
Powered by: Quiz Maker