Q.1

Point out the error in the following program.

#include<stdio.h>
#include<stdarg.h>
fun(...);

int main()
{
    fun(-11.0.66);
    return}
fun(...)
{
    va_list ptr;
    int num;
    va_start(ptr, n);
    num = va_arg(ptr, int);
    printf("%d", num);
}
  • Error: fun() needs return type
  • Error: ptr Lvalue required
  • Error: Invalid declaration of fun(...)
  • No error
Q.2

Point out the error in the following program.

#include<stdio.h>
#include<stdarg.h>
void varfun(int n, ...);

int main()
{
    varfun(-11.0.66);
    return}
void varfun(int n, ...)
{
    float *ptr;
    int num;
    va_start(ptr, n);
    num = va_arg(ptr, int);
    printf("%d", num);
}
  • Error: too many parameters
  • Error: invalid access to list member
  • Error: ptr must be type of va_list
  • No error
Q.3

Point out the error if any in the following program (Turbo C).

#include<stdio.h>
#include<stdarg.h>
void display(int num, ...);

int main()
{
    display('A', 'a', 'b', 'c');
    return}
void display(int num, ...)
{
    char c; int j;
    va_list ptr;
    va_start(ptr, num);
    for(j=j<=num; j++)
    {
        c = va_arg(ptr, char);
        printf("%c", c);
    }
}
  • Error: unknown variable ptr
  • Error: Lvalue required for parameter
  • No error and print A a b c
  • No error and print 4 A a b c
Q.4

Point out the error in the following program.

#include<stdio.h>
#include<stdarg.h>
void varfun(int n, ...);

int main()
{
    varfun(-0);
    return}
void varfun(int n, ...)
{
    va_list ptr;
    int num;
    num = va_arg(ptr, int);
    printf("%d", num);
}
  • Error: ptr has to be set at begining
  • Error: ptr must be type of va_list
  • Error: invalid access to list member
  • No error
Q.5

Point out the error in the following program.

#include<stdio.h>
#include<stdarg.h>

int main()
{
    void display(char *s, int numint num...);
    display("Hello",12.13.14.44.0);
    return}
void display(char *s, int numint num...)
{
    double c;
    char s;
    va_list ptr;
    va_start(ptr, s);
    c = va_arg(ptr, double);
    printf("%f", c);
}
  • Error: invalid arguments in function display()
  • Error: too many parameters
  • Error: in va_start(ptr, s);
  • No error
Q.6

Point out the error in the following program.

#include<stdio.h>
#include<stdarg.h>

int main()
{
    void display(int num, ...);
    display(12.13.14.44.3);
    return
}
void display(int num, ...)
{
    float c; int j;
    va_list ptr;
    va_start(ptr, num);
    for(j=j<=num; j++)
    {
        c = va_arg(ptr, float);
        printf("%f", c);
    }
}
  • Error: invalid va_list declaration
  • Error: var c data type mismatch
  • No error
  • No error and Nothing will print
0 h : 0 m : 1 s