Variable Number of Arguments

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

int main()
{
    void display(int num, ...);
    display(4, 12.5, 13.5, 14.5, 44.3);
    return 0;
}
void display(int num, ...)
{
    float c; int j;
    va_list ptr;
    va_start(ptr, num);
    for(j=1; j<=num; j++)
    {
        c = va_arg(ptr, float);
        printf('%f', c);
    }
}

A Error: invalid va_list declaration

B Error: var c data type mismatch

C No error

D No error and Nothing will print

ANS:A - Error: invalid va_list declaration

Use double instead of float in float c;



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.