LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C++ Programming
  • Unspecified Number Of Arguments

C++ Programming

UNSPECIFIED NUMBER OF ARGUMENTS MCQs

Total Questions : 9

Question 1.

What will initialize the list of arguments in stdarg.h header file?


  1.    va_list
  2.    va_start
  3.    va_arg
  4.    none of the mentioned
 Discuss Question
Answer is Option B. -> va_start

None.

Question 2.

Which header file should you include if you are to develop a function that can accept variable 

number of arguments?


  1.    varag.h
  2.    stdlib.h
  3.    stdio.h
  4.    stdarg.h
 Discuss Question
Answer is Option D. -> stdarg.h

None.

Question 3.


What is the output of this program?



1.
#include
2.
#include
3.
using namespace std;
4.
int flue(char c,...);
5.
int main()
6.
{
7.
int x, y;
8.
x = flue('A', 1, 2, 3);
9.
y = flue('1', 1.0,1, '1', 1.0f, 1l);
10.
cout
  1.    6549
  2.    4965
  3.    6646
  4.    compile time error
 Discuss Question
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.


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
  1.    2436
  2.    48697
  3.    1111111
  4.    compile time error
 Discuss Question
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.


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
  1.    32
  2.    23
  3.    48
  4.    compile time error
 Discuss Question
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

Question 6.

What is the maximum number of arguments or parameters that can be
present in one function call?


  1.    64
  2.    256
  3.    255
  4.    16
 Discuss Question
Answer is Option B. -> 256

None.

Question 7.

How can you access the arguments that are manipulated in the function?


  1.    va_list
  2.    arg_list
  3.    both a & b
  4.    none of the mentioned
 Discuss Question
Answer is Option A. -> va_list

None.

Question 8.


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
  1.    4
  2.    5
  3.    6
  4.    7
 Discuss Question
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

Question 9.

Which header file is used to pass unknown number of arguments to function?


  1.    stdlib.h
  2.    string.h
  3.    stdarg.h
  4.    none of the mentioned
 Discuss Question
Answer is Option C. -> stdarg.h

Because the cstdarg defines this header file to process the unknown number of arguments.

  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Abstract Classes
  • Access Control
  • Argument Passing
  • Arrays
  • Booleans
  • C++ Concepts
  • Catching Exceptions
  • Character Types
  • Class Hierarchies And Abstract Classes
  • Class Hierarchies Introduction
  • Classes
  • Comments And Indentation
  • Complex Number Type
  • Constants
  • Constructors And Destructors
  • Container Design
  • Conversion Operators
  • Declaration
  • Default Arguments
  • Dereferencing
  • Derivation And Templates
  • Derived Classes
  • Design Of Class Hierarchies
  • Enumerations
  • Error Handling
  • Error Handling Alternatives
  • Essential Operators
  • Exception Specifications
  • Exceptions
  • Exceptions And Efficiency
  • Exceptions That Are Not Errors
  • Floating Point Types
  • Free Store
  • Friends
  • Function Call
  • Function Declarations
  • Function Templates
  • Functions
  • Grouping Of Exceptions
  • Header Files Usage
  • Increment And Decrement
  • Integer Types
  • Large Objects
  • Linkage
  • Macros
  • Modularization And Interfaces
  • Multiple Inheritance
  • Namespaces
  • Objects
  • Objects And Classes
  • Oops Concepts
  • Operator Functions
  • Operators
  • Overloaded Function Names
  • Pointer To Function
  • Pointer To Void
  • Pointers
  • Pointers Into Arrays
  • Pointers To Members
  • References
  • Resource Management
  • Run Time Type Information
  • Sequence Adapters
  • Sequences
  • Simple String Template
  • Sizes
  • Specialization
  • Standard Exceptions
  • Standard Library Design
  • Statements
  • String Class
  • Structures
  • Subscripting
  • Template Arguments To Specify Policy Usage
  • Types
  • Uncaught Exceptions
  • Unspecified Number Of Arguments
  • User Defined Types
  • Value Return
  • Vector
  • Void

Recent Posts

  • Vedic Maths Faq
  • Sail E0 Exam Results Cancelled - Exam Will Be Rescheduled
  • Best Ssc Exam For Girls
  • Is Ssc Difficult Than Upsc?
  • Quantitative Aptitude Faqs
  • Ssc Exam Guide Book
  • Sail E0 Results 2022

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

Topics

Computer Aptitude
SAIL Junior Officer (E-0)
10th Grade
11th Grade
12th Grade
4th Grade
5th Grade
6th Grade
7th Grade
8th Grade
9th Grade
NCERT
Cat
Commerce
Computer Science
Engineering
English
General Knowledge
Ias
Management
Quantitative Aptitude
Reasoning Aptitude
General Studies (Finance And Economics)
Vedic Maths
Analytical Instrumentation
Biochemistry
Bioinformatics
Biology
Biotechnology
Bitsat
Business Statistics
C Programming
C++ Programming
Cell Biology
Chemistry
Cost Accounting
Drug And Pharmaceutical Biotechnology
Electrical Measurement And Instrumentation
Environment Management
Environmental Biotechnology
Enzyme Technology
Financial Management And Financial Markets
Gate
General Science
Geography
Heat Transfer
History And National Movements
Human Anatomy And Physiology
Human And Cultural Diversity
Human Resource Management
Indian Economy
Indian Geography
Indian History
Indian Polity
Instrumentation Transducers
International Relations
Life Sciences
Marketing And Marketing Management
Mass Transfer
Mechanics Of Materials
Microbiology
Neet
Professional Communication
Renewable Energy
Sociology
Surveying
Total Quality Management
Uidai Aadhaar Supervisor Certification
Virology
LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password