adplus-dvertising
frame-decoration

Question

What will be the output of the program?
#include<stdio.h>
#include<stdarg.h>
void fun1(char, int, int *, float *, char *);
void fun2(char ch, ...);
void (*p1)(char, int, int *, float *, char *);
void (*p2)(char ch, ...);

int main()
{
    char ch='A'; int i=10;
    float f=3.14; char *p="Hello";
    p1=fun1;
    p2=fun2;
    (*p1)(ch, i, &i, &f, p);
    (*p2)(ch, i, &i, &f, p);
    return 0;
}
void fun1(char ch, int i, int *pi, float *pf, char *p)
{
    printf("%c %d %d %f %s \n", ch, i, *pi, *pf, p);
}
void fun2(char ch, ...)
{
    int i, *pi; float *pf; char *p;
    va_list list;
    printf("%c ", ch);
    va_start(list, ch);
    i = va_arg(list, int);
    printf("%d ", i);
    
    pi = va_arg(list, int*);
    printf("%d ", *pi);
    pf = va_arg(list, float*);
    printf("%f ", *pf);
    p = va_arg(list, char *);
    printf("%s", p);
}

a.

A 10 3.14A 10 3.14

b.

A 10 10 3.140000 HelloA 10 10 3.140000 Hello

c.

A 10 HelloA 10 Hello

d.

Error

Posted under C Programming

Answer: (b).A 10 10 3.140000 HelloA 10 10 3.140000 Hello

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the program?

Similar Questions

Discover Related MCQs

Q. What are the different types of real data type in C ?

Q. What will you do to treat the constant 3.14 as a long double?

Q. Which of the following range is a valid long double (Turbo C in 16 bit DOS OS) ?

Q. We want to round off x, a float, to an int value, The correct way to do is

Q. The binary equivalent of 5.375 is

Q. A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?

Q. What will you do to treat the constant 3.14 as a float?

Q. Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ?

Q. Declare the following statement?
"An array of three pointers to chars".

Q. What do the following declaration signify?
int *ptr[30];

Q. Declare the following statement?
"A pointer to an array of three chars".

Q. What do the following declaration signify?
char *arr[10];

Q. What do the following declaration signify?
int (*pf)();

Q. Declare the following statement?
"A pointer to a function which receives an int pointer and returns float pointer".

Q. What do the following declaration signify?
void *cmp();

Q. Declare the following statement?
"A pointer to a function which receives nothing and returns nothing".

Q. What do the following declaration signify?
int *f();

Q. What do the following declaration signify?
void (*cmp)();

Q. What do the following declaration signify?
char **argv;

Q. What do the following declaration signify?
char *scr;