💻 Unit 1 – Part A (2-Mark Q&A)

C Programming

⬅ Back to Unit 1

Ad Space

Part A: 2-Mark Questions

1. Define structured programming

C is a structured programming language because it provides functions that enable us to break the code into small, manageable parts. This makes C programs easier to understand and modify. Functions also offer code reusability.

2. What is the purpose of a flowchart in problem-solving?

A flowchart is used in problem-solving to represent the logical sequence of steps in a program using standard symbols. This visual representation makes the program's logic easier to understand, analyze, and debug.

For Loop Flowchart

3. Write pseudo code to find the sum of n numbers

  1. Start
  2. Read n
  3. Initialize sum = 0, i = 1
  4. Repeat steps 5 and 6 while in
  5. Read number
  6. sum = sum + number
  7. i = i + 1
  8. Print sum
  9. Stop

4. Differentiate break and continue statements in C.

Break Statement Continue Statement
Used to terminate the loop or switch statement immediately. Used to skip the current iteration and continue with the next iteration of the loop.
Control transfers to the first statement after the loop/switch. Control transfers back to the loop condition for re-evaluation.
Example: Exits the loop when a certain condition is met. Example: Skips printing a value and goes to the next loop cycle.
Commonly used in switch and loops. Only used in loops.

5. Draw the structure of C program

Structure of a C Program

The main parts of a C program are:

Code Example:

#include <stdio.h> // Preprocessor Directive

int main()         // Main Function
{
    // Declarations & Statements
    printf("Hello, World!\n"); // Example statement
    
    // Return Statement
    return 0;
}

6. What is the purpose of format specifier I/O statements?

The purpose of format specifiers is to tell the compiler what type of data is being read from the user (in scanf()) or printed to the screen (in printf()).

7. Define programming Paradigm.

A programming paradigm is the fundamental style of computer programming. It determines how problems are solved and how solutions are represented in code.

Types:

  1. Imperative / Procedural Programming (like C)
  2. Object-Oriented Programming (OOP)
  3. Functional Programming
  4. Logical Programming

8. What are keywords? Give an example.

Keywords are reserved words in C that have a predefined meaning and purpose. They cannot be used as identifiers (like variable or function names) because they are part of the C language syntax.

Example: int, float, if, while, return

Ad Space