Computer Science XII - C Language Exam Questions
Computer Science XII - C Language Exam Questions
Note: These questions are designed based on the syllabus provided in the image.
1. What is the size of an int data type in a typical 32-bit C compiler?
a) 1 byte
b) 2 bytes
c) 4 bytes
d) 8 bytes
Answer: c) 4 bytes (Note: Size can vary depending on the compiler and architecture)
2. Which data type is used to store character values?
a) int
b) float
c) char
d) string
Answer: c) char
3. Which data type is used to store floating-point numbers?
a) int
b) char
c) double
d) string
Answer: c) double (or float)
1. Which keyword is used to terminate the loop or switch statement immediately?
a) continue
b) return
c) break
d) goto
Answer: c) break
2. Which keyword is used to skip the current iteration and proceed to the next
iteration of a loop?
a) break
b) return
c) continue
d) goto
Answer: c) continue
3. Which keyword is used to transfer control to a labeled statement?
a) break
b) return
c) continue
d) goto
Answer: d) goto
Topic 9: Pointers
1. List the basic data types in C along with their typical sizes.
○ Answer: int (typically 4 bytes), char (1 byte), float (4 bytes), double (8 bytes), void
(0 bytes). (Sizes may vary based on the system).
2. What is the difference between float and double data types?
○ Answer: Both are for floating-point numbers. double provides higher precision
and a larger range than float. double typically uses 8 bytes, while float uses 4
bytes.
1. Explain the difference between logical AND (&&) and bitwise AND (&) operators.
○ Answer: Logical AND (&&) operates on boolean values (true/false) and returns
true only if both operands are true. Bitwise AND (&) operates on individual bits of
integers.
2. List and briefly explain any three types of operators in C.
○ Answer:
■ Arithmetic Operators: (+, -, *, /, %) for mathematical operations.
■ Relational Operators: (==, !=, >, <, >=, <=) for comparisons.
■ Logical Operators: (&&, ||, !) for logical operations.
■ Assignment Operators: (=, +=, -=, *=, /=, %=) for assigning values.
■ Increment/Decrement Operators: (++ , --) to increase or decrease value
by 1.
1. Explain the use of break and continue statements within loops.
○ Answer: break terminates the loop execution immediately and transfers control to
the statement after the loop. continue skips the current iteration of the loop and
proceeds to the next iteration.
Topic 9: Pointers
1. Describe the basic structure of a C program with a detailed explanation of each
section. Include preprocessor directives, the main() function, and the importance
of delimiters/braces.
○ Answer: (Provide a detailed explanation of each section of a C program structure.
Include:
■ Preprocessor Directives: Explanation of #include, #define, etc., and
their role in preprocessing.
■ Global Declarations: Variables declared outside main().
■ main() function: Entry point, return type, function body.
■ Local Declarations: Variables declared inside main().
■ Executable statements: Code within main().
■ Delimiters/Braces {}: Importance in defining code blocks and function
bodies.
■ Illustrate with a simple example C program and label each section.)
Topic 7: Functions
1. Explain arrays and strings in C. Describe how to declare, initialize, and access
array elements, including 2D arrays. Discuss common string manipulation
functions like gets(), puts(), strlen(), strcpy(), strcat(), and strcmp() with syntax and
examples of their usage.
○ Answer: (Detailed explanation of arrays and strings:
■ Arrays: Definition, declaration, initialization (different ways), accessing
elements using indices, concept of contiguous memory, advantages of
arrays.
■ 2D Arrays: Declaration, initialization, accessing elements using row and
column indices, representation as matrices, examples of use cases.
■ Strings: Definition, representation as char arrays, null termination,
declaration, initialization.
■ String Manipulation Functions: Explain each function listed: gets(),
puts(), strlen(), strcpy(), strcat(), strcmp(). For each function, provide:
■ Purpose and functionality.
■ Syntax.
■ Example code demonstrating its use.)
Topic 9: Pointers
These questions cover the syllabus provided and are designed to test understanding at different
levels. Remember to study each topic thoroughly and practice coding to be well-prepared for
your exam. Good luck!