What is a data structure in computing?
A logical or mathematical model for collecting and organizing data.
What defines an algorithm in computer science?
A set of instructions or rules for solving a problem or task.
What programming paradigms does C++ combine?
Object-oriented programming with procedural C.
Why is C++ considered a multiparadigm language?
Because it combines object-oriented and procedural programming.
For what type of software is C++ especially suitable?
System software such as operating systems.
What two tools does a C++ development environment require?
A text editor and a compiler.
What is the first step in a basic Linux C++ workflow?
Creating a source file.
How do you compile a C++ source file named hello.cpp in Linux?
Using the command .
How do you run the compiled executable named hello in Linux?
By executing .
What must a C++ program include to run properly?
Directives and at least one main function with executable statements.
What is cout used for in C++?
It is the standard output object for printing values or text.
What operator is used with cout to print values?
The stream insertion operator <<.
What is cin used for in C++?
It is the standard input object for reading data from the keyboard.
What operator is used with cin to read input?
The stream extraction operator >>.
Which data types are considered primitive in C++?
int, float, double, boolean, and char
What is a string in C++?
An object or sequence storing text as characters
Why does the extraction operator >> read only one word from input?
Because whitespace terminates the input
What must be called before getline() to read a complete line after formatted input?
cin.ignore()
What characters can C++ identifiers contain?
Letters, digits, and underscores
With which characters must C++ identifiers begin?
A letter or underscore
Are C++ identifiers case-sensitive?
Yes, they are case-sensitive
What characters and words are forbidden in C++ identifiers?
Whitespace, special characters, and reserved words
What does a namespace provide for identifiers like types and functions?
A distinct scope.
How do you access entities inside a namespace from outside?
Using the scope resolution operator ::.
What is a symbolic constant?
A named constant whose initialized value cannot be changed.
What is a function in programming?
A complete subprogram designed to perform a well-defined task.
What are the two types of C++ functions?
Library functions and user-defined functions.
What does a function prototype declare?
The return type, name, and parameter list followed by a semicolon.
What is the purpose of a function prototype?
To allow the function to be implemented later.
Which header provides functions like isdigit and tolower in C++?
The <cctype> header.
What defines a C-string in C programming?
A character array terminated by a null character.
What does the strcat function do with character arrays?
It appends one character array to another.
What is the purpose of the strcmp function?
It compares two strings.
What value does strlen return for a C-string?
The length of the C-string.
What does the push_back function do in a string object?
Inserts a character at the end of the string object.
What happens during a function call in execution?
Execution transfers to the called function until return or end.
With what kinds of arguments can a function be called multiple times?
Literal arguments, variables, or as part of larger expressions.
What allows C++ functions to be overloaded with the same name?
Differences in number or types of parameters.
Can return type alone distinguish overloaded functions in C++?
No, return type alone cannot distinguish overloads.
What does a function template define in C++?
A generic function with types determined at instantiation.
How is a function template instantiated?
By calling its name with template arguments in angle brackets followed by function arguments.
What is the signature of the generic sum template function?
How can the sum template be instantiated for integers and doubles?
As sum<int>(x,y) or sum<double>(n,m).
What is recursion in programming?
A function calling itself to solve smaller problems of the same nature.
How does the Principle of Mathematical Induction prove statements?
By proving a base case, assuming the statement for k, and proving it for k+1.
What are the three steps of mathematical induction?
Prove the base case, assume P(k), then prove P(k+1).
What is the factorial recursion formula?
What is the base case for factorial recursion?
What is the Fibonacci recursion formula?
What are the base cases for Fibonacci recursion?
and
What is the recursive power algorithm formula?
What is the base case for the recursive power algorithm?
When does a recursive sorted-array check return true?
For zero or one element.
What is the recursive formula for summing an array?
with .
What defines a palindrome sequence?
It reads the same left to right and right to left.
How does the recursive digit string to integer conversion algorithm work?
It converts the shorter prefix, multiplies by 10, then adds the final digit.
Who developed C++ and where?
Bjarne Stroustrup at Bell Labs.
In which year did Bjarne Stroustrup develop C++?
1979.
What features does an integrated development environment combine?
Code editing, compilation, and debugging support.
Name four examples of integrated development environments.
Code::Blocks, Eclipse, Sublime Text, and Visual Studio.
What languages does GCC provide compiler front-ends for?
C, C++, Objective-C, Fortran, Ada, and Go.
What additional support does GCC include besides compiler front-ends?
Runtime support libraries.
How does every C++ statement end?
With a semicolon.
What does the C++ compiler ignore in the code?
Whitespace.
What does the setw() manipulator do?
Sets the field width for the next insertion operation.
Which header declares the setw() manipulator?
The <iomanip> header.
What base does the dec manipulator format integers in?
Decimal base.
What base does the oct manipulator format integers in?
Octal base.
What base does the hex manipulator format integers in?
Hexadecimal base.
What does a void function return?
No value.
How can the parameter list of a void function be written?
As empty parentheses or as void.
What value does sqrt(16) return?
4.
What value does pow(5,3) return?
125.
What do size(), length(), and strlen(str.c_str()) return for "Rwanda Coding Academy"?
They each return 21.
Which overload does operate(5,2) select and what does it return?
The integer overload, returning 10.
Which overload does operate(5.0,2.0) select and what does it return?
The double overload, returning 2.5.
What allows a template's arguments to resolve to different types?
Using multiple type parameters like T and U.
What does an auto return type enable in template functions?
Compiler deduction of a common return type to avoid narrowing.
What is the formula for the sum of integers from 1 to n?
What is the recursive formula for the sum of digits of n?
What is the base case for the recursive sum of digits?
What does a recursive palindrome check do when first and last elements differ?
It returns false.
How does a recursive palindrome check proceed when first and last elements match?
It recursively checks the inner sequence.
When does a recursive character printer stop?
At the '\0' character.
What does a recursive character printer do before recursing?
It prints the first character.
Test your knowledge with 57 questions on C++ Functions Recursion and OOP.
1. Which description best defines a data structure?
2. A programmer writes ordered instructions that calculate a solution to a problem; what has the programmer created?
Review the complete course in the study sheet for C++ Functions Recursion and OOP.
See study sheet →Import your course and AI generates flashcards in 30 seconds.
Flashcard generator