Challenge - 5 Problems
Master of Compilation and Execution
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple C++ program with compilation steps
What is the output of this C++ program when compiled and run?
C++
#include <iostream> int main() { int x = 5; int y = 10; std::cout << "Sum: " << (x + y) << std::endl; return 0; }
Attempts:
2 left
💡 Hint
Remember that + operator adds integers, not concatenates strings.
✗ Incorrect
The program adds integers 5 and 10, printing their sum as 15.
🧠 Conceptual
intermediate1:30remaining
Identify the compilation stage that converts source code to machine code
Which stage in the C++ compilation process converts the source code into machine code?
Attempts:
2 left
💡 Hint
Think about when the code is translated into instructions the computer understands.
✗ Incorrect
Compilation translates source code into machine code (object files).
❓ Predict Output
advanced2:30remaining
Output of a program with multiple source files and linking
Given two source files compiled and linked, what is the output when running the program?
C++
// file1.cpp #include <iostream> void greet(); int main() { greet(); return 0; } // file2.cpp #include <iostream> void greet() { std::cout << "Hello from linked file!" << std::endl; }
Attempts:
2 left
💡 Hint
Both files must be compiled and linked together to find greet.
✗ Incorrect
The function greet is defined in file2.cpp and linked to main in file1.cpp, so the output prints correctly.
❓ Predict Output
advanced2:00remaining
What error occurs if a function is declared but not defined?
What error will the compiler or linker produce for this code?
C++
#include <iostream> void foo(); int main() { foo(); return 0; }
Attempts:
2 left
💡 Hint
Declaration exists but no function body is provided.
✗ Incorrect
The compiler compiles fine but linker fails because foo is declared but not defined.
🧠 Conceptual
expert2:30remaining
Order the stages of C++ program compilation and execution
Select the correct order of stages when compiling and running a C++ program.
Attempts:
2 left
💡 Hint
Think about the order from source code to running program.
✗ Incorrect
The correct order is preprocessing, compilation, linking, then execution.