IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C++ Programming C# Programming Java Programming
Microbiology Biochemistry Biotechnology Biochemical Engineering
Civil Engineering Mechanical Engineering Chemical Engineering Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
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 C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

C Programming - Variable Number of Arguments - Discussion

@ : Home > C Programming > Variable Number of Arguments > Point Out Errors - Discussion

Read more:

"Nothing is impossible to a willing heart."
- (Proverb)
7. 

Point out the error in the following program.

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

int main()
{
    varfun(3, 7, -11.2, 0.66);
    return 0;
}
void varfun(int n, ...)
{
    float *ptr;
    int num;
    va_start(ptr, n);
    num = va_arg(ptr, int);
    printf("%d", num);
}

[A]. Error: too many parameters
[B]. Error: invalid access to list member
[C]. Error: ptr must be type of va_list
[D]. No error

Answer: Option B

Explanation:

No answer description available for this question.


Riz said: (Tue, Sep 28, 2010 05:58:05 AM)    
 
Can anyone explain?

Rujuta Kelkar said: (Thu, Jul 28, 2011 09:36:52 AM)    
 
PlZ explain. Its kinda difficult to understand. We need more explanation.

Rajan said: (Thu, Aug 18, 2011 06:59:41 PM)    
 
Sir please explain the answer of this question.

Prem said: (Mon, Aug 22, 2011 11:57:55 AM)    
 
Please kindly explain in brief.

Sunil Kumar Yadav said: (Sun, Sep 11, 2011 04:22:11 AM)    
 
Kindly explain in briefly?

Bond said: (Thu, Dec 1, 2011 04:37:59 PM)    
 
Is there any one who can explain it ?

Nuzhat said: (Tue, Dec 6, 2011 03:46:30 PM)    
 
va_list(variable list) is user defined data type...
va_list ptr;
=>argument pointer(ptr) traverse through the variable arguments passed in the function...
va_start(ptr,n);
=>points ptr to the argument, in dis case n ie 3
va_arg
=>moves teh ptr to next variable argument
num = va_arg(ptr, int);
so printf print 7...

Siva said: (Fri, Jan 18, 2013 12:44:17 PM)    
 
We need to declare the pointer *ptr as va_list type because this is variable argument function type.

Write your comments here:
Name *:     Email:


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

Contact us: info@indiabix.com     Follow us on twitter!