C and C++ Coding Flashcards
7 cards from real Online Coding Lessons practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 C and C++ Coding flashcards as text
In C, what is the value of an array name when used in most expressions?
Answer: A pointer to the first element
An array name decays to a pointer to its first element in most contexts.
Which C++ access specifier makes members accessible only within the class itself?
Answer: private
private members can only be accessed from within the same class.
What does the C function strlen return for the string "hello"?
Answer: 5
strlen counts characters up to but not including the null terminator, giving 5.
In C++, what does the 'virtual' keyword enable for a base class function?
Answer: Runtime polymorphism via dynamic dispatch
virtual functions are resolved at runtime, enabling polymorphic behavior through base pointers.
What is the correct format specifier to print a floating-point double with printf in C?
Answer: %f
%f is used to print float and double values with printf.
In C++, which header provides std::cout and std::cin?
Answer:
declares the standard stream objects std::cout and std::cin.
What happens if you call free() twice on the same C pointer?
Answer: Undefined behavior
A double free results in undefined behavior and can corrupt the heap.