C++ Programming
UNSPECIFIED NUMBER OF ARGUMENTS MCQs
Total Questions : 9
Answer is Option B. -> va_start
None.
Answer is Option D. -> stdarg.h
None.
Answer is Option A. -> 6549
In this program, we are returning the ascii value of the character and printing it.
Output:
$ g++ rka4.cpp
$ a.out
6549
Question 4.
1.
#include
2.
#include
3.
using namespace std;
4.
void dumplist(int, ...);
5.
int main()
6.
{
7.
dumplist(2, 4, 8);
8.
dumplist(3, 6, 9, 7);
9.
return 0;
10.
}
11.
void dumplist(int n, ...)
12.
{
13.
va_list p;
14.
int i;
15.
va_start(p, n);
16.
while (n-->0) {
17.
i = va_arg(p, int);
18.
cout
What is the output of this program?
1.
#include
2.
#include
3.
using namespace std;
4.
void dumplist(int, ...);
5.
int main()
6.
{
7.
dumplist(2, 4, 8);
8.
dumplist(3, 6, 9, 7);
9.
return 0;
10.
}
11.
void dumplist(int n, ...)
12.
{
13.
va_list p;
14.
int i;
15.
va_start(p, n);
16.
while (n-->0) {
17.
i = va_arg(p, int);
18.
cout
Answer is Option B. -> 48697
In this program, we are eradicating the first value
by comparing using while operator.
Output:
$ g++ rka3.cpp
$ a.out
48697
Question 5.
1.
#include
2.
#include
3.
using namespace std;
4.
int add (int num, ...)
5.
{
6.
int sum = 0;
7.
va_list args;
8.
va_start (args,num);
9.
for (int i = 0; i < num; i++) {
10.
int num = va_arg (args,int);
11.
sum += num;
12.
}
13.
va_end (args);
14.
return sum;
15.
}
16.
int main (void)
17.
{
18.
int total = add(8, 1, 2, -1, 4, 12, -2, 9, 7);
19.
cout
What is the output of this program?
1.
#include
2.
#include
3.
using namespace std;
4.
int add (int num, ...)
5.
{
6.
int sum = 0;
7.
va_list args;
8.
va_start (args,num);
9.
for (int i = 0; i < num; i++) {
10.
int num = va_arg (args,int);
11.
sum += num;
12.
}
13.
va_end (args);
14.
return sum;
15.
}
16.
int main (void)
17.
{
18.
int total = add(8, 1, 2, -1, 4, 12, -2, 9, 7);
19.
cout
Answer is Option A. -> 32
We are adding these numbers by using for statement and stdarg.
Output:
$ g++ uka.cpp
$ a.out
The result is 32
Answer is Option B. -> 256
None.
Answer is Option A. -> va_list
None.
Question 8.
1.
#include
2.
#include
3.
using namespace std;
4.
float avg( int Count, ... )
5.
{
6.
va_list Numbers;
7.
va_start(Numbers, Count);
8.
int Sum = 0;
9.
for (int i = 0; i < Count; ++i )
10.
Sum += va_arg(Numbers, int);
11.
va_end(Numbers);
12.
return (Sum/Count);
13.
}
14.
int main()
15.
{
16.
float Average = avg(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
17.
cout
What is the output of this program?
1.
#include
2.
#include
3.
using namespace std;
4.
float avg( int Count, ... )
5.
{
6.
va_list Numbers;
7.
va_start(Numbers, Count);
8.
int Sum = 0;
9.
for (int i = 0; i < Count; ++i )
10.
Sum += va_arg(Numbers, int);
11.
va_end(Numbers);
12.
return (Sum/Count);
13.
}
14.
int main()
15.
{
16.
float Average = avg(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
17.
cout
Answer is Option A. -> 4
We are just calculating the average of these numbers using cstdarg.
Output:
$ g++ uka.cpp
$ a.out
Average of first 10 whole numbers 4
Answer is Option C. -> stdarg.h
Because the cstdarg defines this header file to process the unknown number of arguments.
Recent Questions
Q. Reduced Distance Between Last Operating Comb And Drawing Uni....
Q. Lactic Acid Is Formed In ______.
Q. A Varactor Diode Is Used For
Q. Arun Said, "This Girl Is The Wife Of The Grandson Of My Moth....
Q. A Man Swims Relative To Water With A Velocity Greater Than R....
Q. A Dealer Allows A Discount Of 15%. A Customer Pays An Amount....
Q. A Sanguine Outlook Is Associated With The ......
Q. A URL Specifies The Following : (i) Protocol Used (ii) Domai....
Q. Q Factor For A Series Resonant Circuit Is?
Q. Which Of The Following Is Not A Component Of Working Capital....
Q. Indipaisa Has Signed A Partnership Agreement With Which Paym....
Q. Cell Membrane Is Virtually Impermeable To All Ions Except
Q. Media Used For The Production Of Chlorotetracyclin Consists ....
Q. Euler's Equation Of Motion Is A Statement Expressing
Q. Which Command Allows You To View Your File 24 Lines At A Tim....
Q. Which Of The Following Branch Of Physics Deal With Study Of ....
Q. If Nucleon (mass) And Proton (atomic) Number Is 40 And 20 Re....
Q. in One Hour, A Boat Goes 11 Km . Along The Steam And 5 Km ....
Q. In Addition To The RNA Polymerase, There Are Also A Number O....
Q. Width Of Complete Chain Of Cellulose Fibre Is