Menu

1 / 2

10 C++ Interview Questions Every Beginner Should Be Able to Answer

DEV Community: cpp·Farhan Ahmad·about 14 hours ago
#PSsHeN9q
#devtocpp#devto#dev#value#difference
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.