📋 Answer Key

Sessions 1-6 Comprehensive Test - Student Version

🎯 Section 1: Basic Programming Concepts (20 points)

Q1. What does C stand for in programming? (4 points)

Answer: C) A programming language

Q2. Which of these is NOT a programming language? (4 points)

Answer: D) HTML

Q3. What does IDE stand for? (4 points)

Answer: B) Integrated Development Environment

Q4. Why is C called a "foundation" language? (8 points)

Answer: C gives you complete control over the computer's memory and hardware. Many other programming languages like Python and Java are actually built using C. Learning C teaches you how computers really work at a low level, which makes it easier to understand any other programming language later.

🏗️ Section 2: Program Structure & Syntax (25 points)

Q5. What does #include do? (5 points)

Answer: B) Includes input/output functions like printf

Q6. Every C statement must end with: (5 points)

Answer: C) A semicolon (;)

Q7. Find and fix the errors in this code: (15 points)

Errors Found:
  1. Missing semicolon after first printf
  2. Printf should be printf (C is case sensitive)
  3. Missing semicolon after return 0
#include <stdio.h> int main() { printf("Hello World!\n"); printf("Welcome to C programming"); return 0; }

📊 Section 3: Variables & Data Types (25 points)

Q8. Which data type stores whole numbers? (5 points)

Answer: A) int

Q9. What is the correct way to declare a variable? (5 points)

Answer: B) int age;

Q10. Which format specifier is used for integers? (5 points)

Answer: A) %d

Q11. Write a program that declares variables and displays them: (10 points)

#include <stdio.h> int main() { int age = 20; float height = 5.8; char grade = 'A'; printf("Age: %d\n", age); printf("Height: %.1f\n", height); printf("Grade: %c\n", grade); return 0; }

🧮 Section 4: Arithmetic Operations (30 points)

Q12. What is 15 % 4? (5 points)

Answer: 3

Q13. What is 10 / 3 in integer division? (5 points)

Answer: 3

Q14. What is the result of (2 + 3) * 4? (5 points)

Answer: 20

Q15. Write a program that calculates the area of a rectangle: (15 points)

#include <stdio.h> int main() { float length, width, area; printf("Enter length: "); scanf("%f", &length); printf("Enter width: "); scanf("%f", &width); area = length * width; printf("Area: %.2f\n", area); return 0; }