Urgent.News

What's breaking now, across thousands of outlets.

Tech

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

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…

1. What is the difference between = and == ? The assignment operator = assigns a value to a variable (x = 5). Meanwhile, the equality operator == compares two values to check if they are equal (if (x == 5)). Using if (x = 5) works in compilation but always evaluates to true due to the assignment, leading to potential bugs.

2. What sets a compiler apart from an interpreter? A compiler converts the entire program into machine code before execution (as in C++). An interpreter, on the other hand, interprets and executes code line by line, similar to Python.

3. Among the basic data types in C++, which ones are fundamental? C++ includes int for whole numbers, float and double for decimals, char for single characters, and bool for true/false values. std::string is utilized for handling text data.

4. How do while and do-while loops differ? While checks the condition prior to executing the loop body, potentially causing the loop to run zero times. Conversely, do-while evaluates the condition at the loop's end, ensuring execution at least once.

5. What is the purpose of a function in programming, and why should one be used? A function is a named segment of code that performs a single task. By employing functions, you minimize code repetition, simplify testing, and enhance code readability.

6. What is the distinction between pass by value and pass by reference? In pass by value, a function receives a copy of the variable, so modifications within the function do not affect the original variable. Pass by reference, using the reference operator &, allows the function to manipulate the original variable directly.

7. What constitutes an array in C++? An array is a fixed-size collection of elements, all of the same data type, stored sequentially in memory. Array indices initiate at 0; for instance, an array of size 5 (int a[5]) encompasses elements from a[0] to a[4].

8. Can you explain the concept of a pointer? A pointer is a variable that stores the memory address of another variable. For example, int *p = &x; assigns the address of x to pointer p, and *p retrieves the value of x.

9. How do structures and classes differ in C++? Both structures and classes serve to encapsulate related data. However, by default, members of a struct are public, while those of a class are private, revealing a difference in their access levels.

10. Why is return 0; included when defining main() in a C++ program? The return 0; statement indicates to the operating system that the program concluded without any errors. In contrast, a non-zero return value typically signifies an error during program execution.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

The Small Web is Huge

Speaker Page: https://pretalx.seagl.org/2026/talk/GQZEUY/ Additional Notes: https://punkto.org/blog/small_web Comments

The Demo Dies at Minute Nine: A Bootcamp Lab on Rehearsing Agent Failures

Your agent demo will not fail because the model is dumb. It will fail at minute nine, when the room goes quiet and the second request hangs. So this lab grades the slow path.

  • Lab focuses on rehearsing agent failures, not successful outcomes
  • Students build tool-using agent, simulate latency and rejected requests
  • Demo runs nine minutes, highlights importance of prompt resilience

The Protocol That Holds the Internet Together and Keeps Breaking It

On the morning of October 4, 2021, hundreds of millions of people tried to open Facebook, Instagram, and WhatsApp and found nothing. Not an error message. Not a spinning wheel. Nothing.

  • BGP, internet's routing protocol, fails due to routine configuration change
  • BGP, foundational internet system, lacks authentication and trust-based
  • BGP, designed in 1989, still governs internet routing in 2026

Free Tokens Don't Cut the Bill. They Move It.

Free tokens don't cut the bill. They move it. That is the whole finding, and it is why I rebuilt my evaluation harness before I sent a single prompt through a free model endpoint.

  • Free tokens do not reduce overall AI model costs; they shift expenses to evaluation process.
  • Evaluation cost includes time, computing resources, and human attention.
  • Oracle check is crucial evaluation criterion; should be reliably checkable by machine.

More from Monday 26 October →