InidBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming Java Programming
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Group Disucssion HR Interview Questions Technical Interview Questions Body Language
"I never think of the future. It comes soon enough."
- Albert Einstein

C Programming - Variable Number of Arguments - Discussion

@ : Home > C Programming > Variable Number of Arguments > Find Output of Program - Discussion
2. 

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.14
A 10 3.14
[B].
A 10 10 3.140000 Hello
A 10 10 3.140000 Hello
[C]. A 10 Hello
A 10 Hello
[D]. Error

Answer: Option B

Explanation:

No answer description available for this question.


Write your comments here:


© 2008-2010 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy