What will be the output of the following C++ code?
#include <iostream>
#include <stdarg.h>
using namespace std;
void fun(std::string msg, ...);
int main()
{
fun("cPlusPlus", 1, 4, 7, 11, 0);
return 0;
}
void fun(std::string msg, ...)
{
va_list ptr;
int num;
va_start(ptr, msg);
num = va_arg(ptr, int);
num = va_arg(ptr, int);
cout << num;
}
#include <iostream>
#include <stdarg.h>
using namespace std;
void fun(std::string msg, ...);
int main()
{
fun("cPlusPlus", 1, 4, 7, 11, 0);
return 0;
}
void fun(std::string msg, ...)
{
va_list ptr;
int num;
va_start(ptr, msg);
num = va_arg(ptr, int);
num = va_arg(ptr, int);
cout << num;
}A. 6
B. 5
C. 8
D. 4
Answer: Option D

Join The Discussion