Variable Number of Arguments

Q1:
What will be the output of the program?
#include<stdio.h>
#include<stdarg.h>
void fun1(int num, ...);
void fun2(int num, ...);

int main()
{
    fun1(1, 'Apple', 'Boys', 'Cats', 'Dogs');
    fun2(2, 12, 13, 14);
    return 0;
}
void fun1(int num, ...)
{
    char *str;
    va_list ptr;
    va_start(ptr, num);
    str = va_arg(ptr, char *);
    printf('%s ', str);
}
void fun2(int num, ...)
{
    va_list ptr;
    va_start(ptr, num);
    num = va_arg(ptr, int);
    printf('%d', num);
}

A Dogs 12

B Cats 14

C Boys 13

D Apple 12

ANS:A - Dogs 12

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.