Home / Programming Questions / C++ MCQs / Page 1
Dear candidates you will find MCQ questions of C++ here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question
U
Q. What will initialize the list of arguments in stdarg.h header file?
U
Q. What is the output of this program?
#include #include using namespace std; void function(std::string message, ...); int main() { function("UdayMCQBuddy", 5, 7, 10, 8, 9); return 0; } void function(std::string message, ...) { va_list ptr; int number; va_start(ptr, message); number = va_arg(ptr, int); number = va_arg(ptr, int); cout << number; }
U
Q. Which header file should you include if you are to develop a function that can accept variable number of arguments?
U
Q. What is the output of this program?
#include #include using namespace std; int funcion(char ch,...); int main() { int p, q; p = funcion('B', 2, 3, 4); q = funcion('3', 2.0, 2, '3', 2.0f, 10); cout << p<<" " << q; return 0; } int funcion(char ch,...) { return ch; }
U
Q. What is the output of this program?
#include #include using namespace std; void List(int, ...); int main() { List(2, 5, 10); List(3, 6, 9, 7); return 0; } void List(int num, ...) { va_list a; int k; va_start(a, num); while (num-->0) { k = va_arg(a, int); cout << k; } va_end(a); }
U
Q. What is the output of this program?
#include #include using namespace std; int Addition(int number, ...) { int sum = 0; va_list args; va_start (args,number); for (int i = 0; i < number; i++) { int number = va_arg (args,int); sum += number; } va_end (args); return sum; } int main (void) { int Result = Addition(1, 10, 9, -1, 13, 23, -2, 9, 17); cout << "The result is " << Result; return 0; }
U
Q. What is the maximum number of arguments or parameters that can be present in one function call?
U
Q. What is the output of this program?
#include #include using namespace std; float avg( int Count, ... ) { va_list num; va_start(num, Count); int Sum = 0; for (int i = 0; i < Count; ++i ) Sum += va_arg(num, int); va_end(num); return (Sum/Count); } int main() { float AVG = avg(5, 0, 1, 2, 3, 4); cout << "Average of first 5 whole numbers : " << AVG; return 0; }
Don't have account? Register here.