Variable Number of Arguments

Q1:
Point out the error in the following program.
#include<stdio.h>
#include<stdarg.h>

int main()
{
    void display(char *s, int num1, int num2, ...);
    display('Hello', 4, 2, 12.5, 13.5, 14.5, 44.0);
    return 0;
}
void display(char *s, int num1, int num2, ...)
{
    double c;
    char s;
    va_list ptr;
    va_start(ptr, s);
    c = va_arg(ptr, double);
    printf('%f', c);
}

A Error: invalid arguments in function display()

B Error: too many parameters

C
Error: in va_start(ptr, s);

D No error

ANS:A - Error: invalid arguments in function display()

We should have use va_start(ptr, num2);



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.