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
  • Comments And Indentation

C++ Programming

COMMENTS AND INDENTATION MCQs

Total Questions : 11

Page 1 of 2 pages
Question 1.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
void Sum(int a, int b, int & c)
4.
{
5.
a = b + c;
6.
b = a + c;
7.
c = a + b;
8.
}
9.
int main()
10.
{
11.
int x = 2, y =3;
12.
Sum(x, y, y);
13.
cout
  1.    2 3
  2.    6 9
  3.    2 15
  4.    compile time error
 Discuss Question
Answer is Option C. -> 2 15

We have passed three values and it will manipulate according to the given condition and yield the 

result as 2 15.
Output:
$ g++ arg.cpp
$ a.out
2 15

Question 2.

What will happen when we use void in argument passing?


  1.    It will not return value to its caller
  2.    It will return value to its caller
  3.    both a & b are correct
  4.    none of the mentioned
 Discuss Question
Answer is Option A. -> It will not return value to its caller

As void is not having any return value, it will not return the value to the caller.

Question 3.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
int add(int a, int b);
4.
int main()
5.
{
6.
int i = 5, j = 6;
7.
cout
  1.    11
  2.    12
  3.    13
  4.    compile time error
 Discuss Question
Answer is Option C. -> 13

The value of a has been changed to 7, So it returns as 13.
Output:
$ g++ arg1.cpp
$ a.out
13

Question 4.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
void square (int *x)
4.
{
5.
*x = (*x + 1) * (*x);
6.
}
7.
int main ( )
8.
{
9.
int num = 10;
10.
square(&num);
11.
cout
  1.    100
  2.    compile time error
  3.    144
  4.    110
 Discuss Question
Answer is Option D. -> 110

We have increased the x value in operand as x + 1, so it will return as 110.
Output:
$ g++ arg2.cpp
$ a.out
110

Question 5.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
long FACTORIAL (long a)
4.
{
5.
if (a > 1)
6.
return (a * factorial (a + 1));
7.
else
8.
return (1);
9.
}
10.
int main ()
11.
{
12.
long num = 3;
13.
cout
  1.    6
  2.    24
  3.    segmentation fault
  4.    compile time error
 Discuss Question
Answer is Option C. -> segmentation fault

As we have given in the function as a+1, it will exceed the size and so it arises the segmentation fault.
Output:
$ g++ arg3.cpp
$ a.out
segmentation fault

Question 6.

What is the use of the indentation in c++?


  1.    distinguishes between comments and code
  2.    r distinguishes between comments and outer data
  3.    both a and b
  4.    none of the mentioned
 Discuss Question
Answer is Option A. -> distinguishes between comments and code

None.

Question 7.

What is used to write multi line comment in c++?


  1.    /* ---- */
  2.    /$ ---- $/
  3.    //
  4.    none of the mentioned
 Discuss Question
Answer is Option A. -> /* ---- */

The /* is used to write the multi line comment.

Question 8.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
/* this is comment*
6.
cout
  1.    hello world
  2.    hello
  3.    compile time error
  4.    none of the mentioned
 Discuss Question
Answer is Option C. -> compile time error

Because the slash should need to be forward not backward.

Question 9.

What is a comment in c++?


  1.    comments are parts of the source code disregarded by the compiler
  2.    comments are executed by compiler to find the meaning of the comment
  3.    comments are executable
  4.    none of the mentioned
 Discuss Question
Answer is Option A. -> comments are parts of the source code disregarded by the compiler

Comments are used to add meaning to the program.

Question 10.

What type of comments does c++ support?


  1.    single line
  2.    multi line
  3.    single line and multi line
  4.    none of the mentioned
 Discuss Question
Answer is Option C. -> single line and multi line

None.

  • 1
  • 2
  • Next →
  • 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.   In Each Question, The First And The Last Sentences Of The Pa....

Q.   His Death Is A Great Blow, Most Terrible To . . . . . . . .

Q.   Azure Blob Storage Offers How Many Storage Tiers?

Q.   Find Out Whether There Is Any Grammatical Error In Below Sen....

Q.   In Power Point, This Is A Container For Text Or Graphics.

Q.   Symmetric Multiprocessing (SMP) Architectures Are Useful For....

Q.   It Is An Instrument That Entitles The Holder To A Proportio....

Q.   In Each Question Below A Sentence Broken Into Four Or Five P....

Q.   The Playground Of Lawn Tennis Is Called

Q.   How Many Numbers (N) Can We Have, Such That 100<N<1000....

Q.    a Button That Makes Characters Either Upper Or Lower Case ....

Q.    the Area Of A Rectangle Is 45 Cm². If Its Length Is 9 Cm,....

Q.   Which Of The Following Presentation Elements Can You Modify ....

Q.   Di....

Q.   Adversity

Q.   1 U = _______ Nanokatals.

Q.   The Manner In Which Bombs Exploded In Five Trains With In A ....

Q.   Spiny Seeds With Hooks are Dispersed By Animals.

Q.   The Process Of Improving The Cutting Action Of The Grinding ....

Q.   To Meet The Educational Needs Of The People, The Madarasa-I ....

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