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
  • Default Arguments

C++ Programming

DEFAULT ARGUMENTS MCQs

Total Questions : 9

Question 1.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
int func(int m = 10, int n)
4.
{
5.
int c;
6.
c = m + n;
7.
return c;
8.
}
9.
int main()
10.
{
11.
cout
  1.    15
  2.    10
  3.    compile time error
  4.    none of the mentioned
 Discuss Question
Answer is Option C. -> compile time error

We can't use the user argument infront of the default argument.

Question 2.

What is the default return type of a function ?


  1.    int
  2.    void
  3.    float
  4.    char
 Discuss Question
Answer is Option B. -> void

None.

Question 3.

If we start our function call with default arguments means, what will be proceeding arguments?


  1.    user argument
  2.    empty arguments
  3.    default arguments
  4.    none of the mentioned
 Discuss Question
Answer is Option C. -> default arguments

As a rule, the default argument must be followed by default arguments only.

Question 4.

What we can’t place followed by the non-default arguments?


  1.    trailing arguments
  2.    default arguments
  3.    both a & b
  4.    none of the mentioned
 Discuss Question
Answer is Option B. -> default arguments

None.

Question 5.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
void Values(int n1, int n2 = 10)
4.
{
5.
using namespace std;
6.
cout
  1.    trailing arguments
  2.    default arguments
  3.    both a & b
  4.    none of the mentioned
 Discuss Question
Answer is Option B. -> default arguments

Answer:  (a)

Explanation:  In this program, We are passing the values as by default values rules it is working.
Output:
$ g++ def2.cpp
$ a.out
1st value: 1
2nd value: 10
1st value: 3
2nd value: 4

Question 6.


What is the output of this program?



1.
#include
2.
#include
3.
using namespace std;
4.
string askNumber(string prompt = "Please enter a number: ");
5.
int main()
6.
{
7.
string number = askNumber();
8.
cout
  1.    5
  2.    6
  3.    the number you entered
  4.    compile time error
 Discuss Question
Answer is Option C. -> the number you entered

In this program, we are getting a number and printing it.
Output:
$ g++ def1.cpp
$ a.out
Please enter a number:
5
Here is your number:5

Question 7.

If the user didn’t supply the value, what value will it take?


  1.    default value
  2.    rise an error
  3.    both a & b
  4.    none of the mentioned
 Discuss Question
Answer is Option A. -> default value

If the user didn’t supply the value means, the compiler will take the given value in the argument list.

Question 8.

Where can the default parameter be placed by the user?


  1.    leftmost
  2.    rightmost
  3.    both a & b
  4.    none of the mentioned
 Discuss Question
Answer is Option B. -> rightmost

None.

Question 9.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
void func(int a, bool flag = true)
4.
{
5.
if (flag == true ) {
6.
cout
  1.    Flag is true. a = 200
  2.    Flag is false. a = 100
  3.    Flag is false. a = 200
  4.    Flag is true. a = 100
 Discuss Question
Answer is Option C. -> Flag is false. a = 200

In this program, we are passing the value, as it evaluates to false, it produces the output as following.
Output:
$ g++ def.cpp
$ a.out
Flag is false. a = 200

  • 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

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)
  • 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

Recent Questions

Q.   The Most Important Consideration In Power Amplifier Is _____....

Q.   Choose The Odd One Out.

Q.   AirAsia Group Of Which Country Has Changed The Name Of Its L....

Q.   Direction Of Twist 'Z' Is

Q.   .................. Is Your Problem?

Q.   Nyquist Plot Provides Information About Absolute Stability A....

Q.   International Women's Day Is Being Celebrated On Which Date?....

Q.   A) D

Q.   Two Students Measure A Particular Length Using The Same Inst....

Q.   Light Or Heat Is Required For Which Step In The Halogenatio....

Q.   In India, The Temperate Forest Research Centre Is In Which C....

Q.   Electrophoresis Of Histones And Myoglobin Under Non-denaturi....

Q.   The Units Of Polarization Of Dielectric Are

Q.   Choose The Alternative Which Is Closely Resembles The Water-....

Q.   The Impulse Turbine Rotor Efficiency Will Have A Maximum Val....

Q.   How Much A Month Are You Paid ?

Q.   Who Has Been Awarded The Top EU Human Rights Prize- The Sakh....

Q.   Identify The Programmable Interval Timer From The Following

Q.   In Nature, Magnesium Oxide (MgO) Is

Q.   A Person Bought Two Articles A And B For Rs.5,000. He Sold A....

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
  • YouTube Channel
  • Maths Fast Trick
  • 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