Search Placementyogi.com
 

C Variable Number of Arguments Objective Questions and Answers

  :: Topics ::

1

Which header file should be included for a function which accepts variable number of arguments?

A.

#include<vararg.h>

B.

#include<stdlib.h>

C.

#include<stdio.h>

D.

#include<stdarg.h>

See Answer & Explanation Lets Discuss
Correct answer is : D
Explanation

No explanation available. Let's Discuss

 
2

What is the output of the following program?

#include <stdio.h>
#include <stdarg.h>
int average(int num,...)
{
    va_list valist;
    int sum = 0,i;

    va_start(valist, num);

    for (i = 0; i < num; i++)
    {
       sum += va_arg(valist, int);
    }

    va_end(valist);

    return sum/num;
}

int main()
{
   printf("Average of 1,2,3 = %d\t", average(1,2,3));
   printf("Average of 4, 5, 6, 7 = %d\n", average(4, 5,6,7));
}
A.

Error

B.

Average of 1,2,3 = 2 Average of 4, 5, 6, 7 = 4

See Answer & Explanation Lets Discuss
Correct answer is : B
Explanation

No explanation available. Let's Discuss

 
3

What is the output of the following program?

#include<stdio.h>
#include<stdarg.h>
void fun(char *msg, ...);

int main()
{
    fun("Nothing Specific : ", 1, 4, 7, 11, 0);
    return 0;
}
void fun(char *msg, ...)
{
    va_list ptr;
    int num;
    va_start(ptr, msg);
    num = va_arg(ptr, int);
    num = va_arg(ptr, int);
    printf("%d", num);
}
A.

1

B.

4

C.

7

D.

Nothing Specific 1

See Answer & Explanation Lets Discuss
Correct answer is : B
Explanation

No explanation available. Let's Discuss

 
4

Can we pass a variable argument list to a function at run-time?

A. Yes
B. No
See Answer & Explanation Lets Discuss
Correct answer is : B
Explanation

Nope! because every actual argument list must be known at compile time. 

 
5

Is it necessary that in a function which accepts variable argument list there should be at least one fixed argument?

A. Yes
B. No
See Answer & Explanation Lets Discuss
Correct answer is : A
Explanation

No explanation available. Let's Discuss

 
 

Banner to LogicGuns.com

Hide Page Information

C Variable No. of Arguments Objective Questions and Answers for Written Round Interview

Here you can find C Variable No. of Arguments Objective Questions with answers and explanation. We have a vast collection of Objective Questions on Variable No. of Arguments in C that will help you a lot!

Why learn C Variable No. of Arguments?

Variable No. of Arguments are an integral part of C and many Objective Questions in the written round are asked from this topic.In this section you can learn and practice C Variable No. of Arguments (Objective Questions with Answers) to improve your skills in order to face the interview and clear campus and off-campus selection of TCS, Infosys, Wipro etc.

Where can I get C Variable No. of Arguments Objective Questions and Answers with Explanation?

PlacementYogi provides you lots of fully solved C Variable No. of Arguments Objective Questions and answers with explanation. Fully solved examples with detailed answer description, explanation are given and it would be easy to understand.Though we do not have pdf file for C Variable No. of Arguments, We have quiz Objective Questions with answers to help you test yourself..

\n

Where can I get C Variable No. of Arguments Interview Objective Questions and Answers (objective type, multiple choice)?

Here you can find objective type C Variable No. of Arguments Objective Questions and answers for interview and entrance examination.Multiple Answers and true or false type Objective Questions are also provided.

How to solve C Variable No. of Arguments problems?

You can easily solve all kind of Objective Questions based on C Variable No. of Arguments by practicing the exercises (including shortcut Variable No. of Arguments to solve problems) given below.