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.
#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
}
#include, #define, processed before compilationmain(), the mandatory entry pointmain() body — local declarations, statements, control flow0 = success by convention)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 |
signed, unsigned, short, long adjust range/sign (e.g. unsigned int, long long)Derived/composite types: array, pointer, function
User-defined types: struct, union, enum, class (C++), typedef-based aliases
int age; binds an identifier to a data type and reserves memory for itint age = 25; declares and assigns a value in one stepmalloc/new and free/delete)