If you are learning C++ for a university exam, a lab viva, or your first job interview, the same basic questions come up again and again. Here are ten of them with short, clear answers.
1. What is the difference between = and == ?
= assigns a value ( x = 5; ). == compares two values ( if (x == 5) ). Writing if (x = 5) compiles, but it assigns 5 and is always true — a classic bug.
2. What is the difference between a compiler and an interpreter?
A compiler translates the whole program into machine code before it runs (C++ does this). An interpreter translates and runs code line by line (like Python).
3. What are the basic data types in C++?
int (whole numbers), float and double (decimals), char (a single character), and bool ( true / false ). std::string is used for text.
4. What is the difference between while and do-while ?
while checks the condition first, so it may run zero times. do-while checks at the end, so it always runs at least once.
5.…