CSS Computer Science (Optional) — Paper-I, Section-A, Topic II subtopic. How a typical C/C++ program is organized, and the data types available to it.

Anatomy of a Program (C/C++)

#include <stdio.h>      // 1. Preprocessor directives
#define MAX 100          //    (headers, macros)

int globalCount = 0;     // 2. Global declarations

int square(int n) {      // 3. Function prototypes/definitions
    return n * n;
}

int main() {              // 4. main() — program entry point
    int x = 5;             //    local declarations
    x = square(x);         //    statements/processing
    printf("%d", x);       //    output
    return 0;               // 5. return — exit status to OS
}
  1. Preprocessor directives#include, #define, processed before compilation
  2. Global declarations — variables/constants visible to the whole file
  3. Function prototypes and definitions — including main(), the mandatory entry point
  4. main() body — local declarations, statements, control flow
  5. Return statement — sends an exit status back to the operating system (0 = success by convention)

Data Types

Primitive (built-in) types:

Type Typical Size (C/C++) Holds
int 4 bytes Whole numbers
float 4 bytes Single-precision decimal
double 8 bytes Double-precision decimal
char 1 byte Single character
bool (C++) 1 byte true/false
void No value / empty type

Derived/composite types: array, pointer, function

User-defined types: struct, union, enum, class (C++), typedef-based aliases

Variables: Declaration, Scope, Lifetime

Type Conversion