C & C++ Job Exam Cheat Sheet (Detailed)
--- C Language ---
1. Type: Procedural Language
2. Key Headers:
- stdio.h: Standard I/O
- stdlib.h: Memory allocation, conversion
- string.h: String handling
- math.h: Math functions
3. Data Types:
- Basic: int, char, float, double
- Qualifiers: short, long, signed, unsigned
4. Control Structures:
- if, else, switch-case
- loops: for, while, do-while
- break, continue, goto
5. Functions:
- Declaration, definition, calling
- Pass by value, pass by reference (via pointers)
- Recursion
6. Arrays & Strings:
- One-dimensional, multi-dimensional
- String manipulation with functions like strcpy, strlen
7. Pointers:
- Declaration, dereferencing, pointer arithmetic
- Pointers with arrays, functions, and structures
8. Structures & Unions:
- Grouping different data types
- Access via dot (.) and arrow (->) operators
9. File Handling:
- fopen(), fclose(), fprintf(), fscanf(), fread(), fwrite()
Example (C):
#include <stdio.h>
int main() {
int a = 10;
printf("Value: %d", a);
return 0;
--- C++ Language ---
1. Type: Multi-paradigm (Procedural + Object-Oriented)
2. Key Headers:
- iostream: Input/output
- cstdlib, cmath, cstring, fstream
3. OOP Concepts:
- Class, Object, Inheritance, Polymorphism, Abstraction, Encapsulation
4. Constructors & Destructors:
- Constructors initialize objects automatically
- Destructors clean up when object is destroyed
5. Function Overloading & Operator Overloading
6. Access Specifiers: public, private, protected
7. Inheritance:
- Single, Multilevel, Multiple, Hierarchical, Hybrid
8. Polymorphism:
- Compile-time: Function/Operator Overloading
- Run-time: Virtual Functions
9. Templates:
- Function and Class templates (Generic programming)
10. STL (Standard Template Library):
- Containers: vector, list, map, set
- Algorithms: sort, find, reverse
- Iterators
Example (C++):
#include <iostream>
using namespace std;
class Person {
public:
void greet() { cout << "Hello!"; }
};
int main() {
Person p;
p.greet();
return 0;
--- Quick Tips for Job Exams ---
- Know memory allocation functions: malloc, calloc, free
- Understand pointer to pointer, and pointer with arrays
- Practice writing and debugging loops and recursion
- Be confident with class structure and inheritance
- Practice STL usage with vector and map
--- C vs C++ ---
| Feature |C | C++ |
|-----------------|------------------|---------------------------|
| Style | Procedural | Object-Oriented + Procedural |
| I/O | printf, scanf | cout, cin |
| Classes/Objects | No | Yes |
| Encapsulation | No | Yes |
| Templates | No | Yes |
| Function Overload| No | Yes |