SlideShare a Scribd company logo
4
Most read
5
Most read
7
Most read
1. What is computer?
ANS: A computer is a device that can be instructed to carry out sequences of
arithmetic or logical operations automatically via computer programming.
2. What is computer program?
ANS: A computer program is a set of instructions for a computer to follow
3. What is Computer software?
ANS: Computer software is the collection of programs used by a computer
4. Discuss Computer Vs Human?
ANS: Computers understand a language variously known as computer language or machine language.
 Therefore, computers and humans have agreed to sort of meet in the middle, using intermediate
languages
• Humans can speak C++ (sort of), and C++ is converted into machine language for the computer to
understand
5. What is Compilers?
ANS: Translate high-level language to machine language
6. What is source code?
ANS: Sourcecode: the original program in a high level language
7. What is object code?
ANS: the translated version in machine language
• Object code is also referred to as binary code or machine code
8. What is Linker?
• ANS: A Linker combines
• The object code for the programs we write
and
• The object code for the pre-compiled routines
into
The machine language program the CPU can run.
9. Why Do We Need Object-Oriented Programming?
ANS: Object-oriented programming was developed because limitations were discovered in earlier approaches
to programming. To appreciate what OOP does, we need to understand what these limitations are and how
they arose from traditional programming languages.
10. What is procedural language?
ANS: C, Pascal, and similar languages are procedural languages. That is, each statement in the language tells the
computer to do something.
11. What is class?
ANS: A class is a description of a number of similar objects.
12. What is instance of class?
Chapter 1: Object Oriented Programming in C++
ANS: specific people with specific names are members of this class if they possess certain characteristics. An
object is often called an “instance” of a class.
13. What are oo p characteristics?
14. What are the benefits of oop?
ANS:
15. What is Algorithm?
 ANS: Algorithms
◦ A sequence of precise instructions which leads to a solution
 Program
◦ An algorithm expressed in a language the computer can understand
16. How many types the problem solving in c++?
ANS: Problem Solving Phase
Implementation Phase
17. What is Problem solving Phase?
Develop the algorithm before implementation
18. What is implementation Phase?
ANS: Translate the algorithm into a programming
language
19. What are the three errors of programming language?
 Syntaxerrors
 Run-time errors
 Logicerrors
END Chapter1
20. What is Function?
 ANS: Functions are one of the fundamental building blocks of C++. The FIRST program consists almost
entirely of a single function called main ( ).
21. What is comment?
ANS: Comments help the person writing a program, and anyone else who must read the source file,
understand what’s going on.
22. Two types of comment?
 ANS: Single-line comment which begins with // and terminates at the end of the current line.
 Multi-line comment which begins with /* and ends with */.
23. What is Variable?
 ANS: A variable is a location in the computer's memory where a value can be stored for use by a
program.
 All variables must be declared with a name and a data type before they can be used in a program
 Declarations of variables can be placed almost anywhere in a program
 That value is actually placed in the memory space assigned to the variable.
Chapter2 C++Programming Basics
24. Tell the Basic Data base
25. Tell Their Basic Range
26. What is difference B/wee Expressions and Statements?
ANS: Any arrangement of variables, constants, and operators that specifies a computation is called an
expression.
Statements tell the compiler to do something and terminate with a semicolon.
27 Tell the rules of operator precedence?
ANS: PEDMAS (Parentheses, Exponents, Division, Multiplication, Addition and Subtraction)
END Chapter2
Q1: what is called operator that compares two values?
A1: A relational operator.
Q2: what do loops cause?
A2: Loops cause section of your program to be repeated a certain number of times.
Q3: what are three kinds of loops in C++?
• A3:There are three kinds of loops in C++:
• the for loop
• the while loop
• and the do loop
Q4: what is for loop?
A4: The for loop executes a section of code a fixed number of times.
Q5: when for loop used?
A5:It’s usually used when you know, before entering the loop, how many times you want to execute the code.
Q6: when while loop used?
A6: The while loop is used when you do not know how many times you want to do something before you start
the loop.
Q7: when test of while loop is evaluated?
A7: The test expression is evaluated at the beginning of the loop.
Q8: which have higher precedence arithmetic and rational operators?
A8: Note that arithmetic operators have a higher precedence than relational operators
Example (a < b / 2)
Q8: when do loop used?
A8: Use do loop when you want to guarantee that the loop body is executed at least once.
Chapter3 C++Programming Loops
Q9: when test of do while is evaluated?
A9: The test expression is evaluated at the end of the loop.
Q10: what do break and continue statement are used?
A10: break and continue statements are used to alter the flow of loops.
Q11: what are three types of decisions?
A11:
 The if statement
 The if...else statement
 Nested if...else statement
 The switch statement
Q12: what does if statement performs?
A12: The if statement performs an action if a condition is true or skips the action if the condition is false.
END Chapter3
Q1. Define function? And tell the most important reason to use functions?
A1. A function groups a number of program statements into a unit and gives it a name.
The most important reason to use functions is to:
Chapter4 C++ Programming Function
• Divide a program into units (divide & conquer).
• Reduce program size: the function’s code is stored in only one place in memory,
even though the function is executed many times.
Q2.What is the three components necessary to add a function to a program?
A2.The three components necessary to add a function to a program are:
a. the function declaration
b. the calls to the function
c. And the function definition.
Q3.Distinguish the different b/w function declaration, calling and function Definition?
A3. Function Declaration
 Declare the function before it is called
 Notice that the function declaration is terminated with a semicolon.
 Function declarations are also called prototypes, since they provide a model or
blueprint for the function.
 The keyword void specifies that the function has no return value, and the empty
parentheses indicate that it takes no arguments
Function calling
• To call a function we need: the function name, followed by parentheses.
• The syntax of the call is very similar to that of the declaration, except that the
return type is not used.
• The call is terminated by a semicolon.
Function definition
• The definition contains the actual code for the function.
• The definition consists of a line called the declarator, followed by the function
body.
• The declarator must agree with the declaration: It must use the same function
name, have the same argument types in the same order (if there are arguments),
and have the same return type.
• Notice that the declarator is not terminated by a semicolon.
Q4.Define declaration and tell some library functions?
A4.The declaration is in the header file specified at the beginning of the program (conio.h
for getche () and cmath.h for sqrt()).
Some library function such as getche () or sqrt ()?
Q5.What is an argument and parameters?
• An argument is a piece of data passed from a program to the function.
• Arguments allow a function to operate with different values, or even to do
different things, depending on the requirements of the program calling it.
The variables used within the function to hold the argument values are called
parameters.
Q6. What is the different b/w passing by value and passing by reference?
A6.Passing by value
• Passing by value means that the function creates copies of the arguments passed
to it. The called function creates a new variable of the same type as the argument
and copies the argument’s value into it.
• The function cannot access the original variable in the calling program, only the
copy it created.
• Passing arguments by value is useful when the function does not need to modify
the original variable in the calling program.
• In fact, it offers insurance that the function cannot harm the original variable.
Passing by reference
• In passing arguments by reference, a reference to the original variable, in the
calling program, is passed. (It is actually the memory address of the variable that
is passed).
• An important advantage of passing by reference is that:
 The function can access the actual variables in the calling program.
 It provides a mechanism for passing more than one value from the function
back to the calling program.
Q7.Describe Overloaded Functions with example?
A7.An overloaded function performs different activities depending on the kind of data
sent to it. It is more convenient to use functions with the same name even though they
each have different arguments.
Examples
• Declaration:
Voiddrawchar ();
Voiddrawchar (char);
Voiddrawchar (char, int);
• Calling:
Draw char ();
Draw char ('=');
Draw char ('+', 30);
Q8.What is Recursion?
A8.Recursion involves a function calling itself. Recursion is much easier to understand
with an example than with lengthy explanations.
Q9. What is Default Arguments?
A9.A function can be called without specifying all its arguments.
• The default argument follows an equal sign, which is placed directly after the type
name.
• Remember that missing arguments must be the trailing arguments—those at the
end of the argument list.
Q10. Differentiate Scope and Storage Class?
A10.scope
• The scope of a variable determines which parts of the program can access it, and
its storage class determines how long it stays in existence.
• Two different kinds of scope are important here: local and file.
 Variables with local scope are visible only within a block.
 Variables with file scope are visible throughout a file.
Storage Class
• A block is basically the code between an opening brace and a closing brace. Thus
a function body is a block.
• There are two storage classes: automatic and static.
• Variables with storage class automatic exist during the lifetime of the function in
which they are defined.
• Variables with storage class static exist for the lifetime of the program.
END Chapter4
C++ question and answers
C++ question and answers

More Related Content

DOCX
Basic java important interview questions and answers to secure a job
PPTX
Inline function
PPTX
c++ programming Unit 2 basic structure of a c++ program
PPTX
Operators in java
PPTX
Access specifiers(modifiers) in java
PPT
CSCI-383 Lecture 3-4: Abstraction
PPT
Parallel processing
PPTX
Functions in c++
Basic java important interview questions and answers to secure a job
Inline function
c++ programming Unit 2 basic structure of a c++ program
Operators in java
Access specifiers(modifiers) in java
CSCI-383 Lecture 3-4: Abstraction
Parallel processing
Functions in c++

What's hot (20)

PPTX
Inline function in C++
PDF
Java - Interfaces & Packages
PPTX
PDF
Abstraction
PPTX
Deadlock ppt
PPTX
Control Statements in Java
PPT
Types of exceptions
PPT
Control Structures
PPTX
Method overloading
PPTX
This keyword in java
PPTX
Exception Handling in C#
PPTX
Semaphore
PPT
Operators in C++
PPTX
Control structures in c++
PPTX
Operators in java
PPTX
Abstract Class & Abstract Method in Core Java
PPT
Type Casting in C++
PPTX
PPT
Final keyword in java
Inline function in C++
Java - Interfaces & Packages
Abstraction
Deadlock ppt
Control Statements in Java
Types of exceptions
Control Structures
Method overloading
This keyword in java
Exception Handling in C#
Semaphore
Operators in C++
Control structures in c++
Operators in java
Abstract Class & Abstract Method in Core Java
Type Casting in C++
Final keyword in java
Ad

Similar to C++ question and answers (20)

PPTX
c & c++ logic building concepts practice.pptx
PDF
Pc module1
PPTX
C Language Presentation.pptx
PPTX
C programming
PPT
Introduction To Programming subject1.ppt
PPTX
Introduction Of C++
PPTX
assisgnment 2 python.pptx important questions
PPTX
Functions and Header files ver very useful
PPTX
Chapter One Function.pptx
PPTX
Functions in c
PDF
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
PDF
Introduction to c first week slides
PDF
VIT351 Software Development VI Unit1
PPTX
Programming in C and Decision Making Branching
PPTX
Programming in C & Decision Making Branching
PPTX
cbybalaguruswami-e-180803051831.pptx
PPTX
cbybalaguruswami-e-180803051831.pptx
PPTX
Lecture 1
PPTX
FUNCTION CPU
c & c++ logic building concepts practice.pptx
Pc module1
C Language Presentation.pptx
C programming
Introduction To Programming subject1.ppt
Introduction Of C++
assisgnment 2 python.pptx important questions
Functions and Header files ver very useful
Chapter One Function.pptx
Functions in c
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
Introduction to c first week slides
VIT351 Software Development VI Unit1
Programming in C and Decision Making Branching
Programming in C & Decision Making Branching
cbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptx
Lecture 1
FUNCTION CPU
Ad

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
KodekX | Application Modernization Development
PDF
Encapsulation theory and applications.pdf
PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
KodekX | Application Modernization Development
Encapsulation theory and applications.pdf
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation_ Review paper, used for researhc scholars
MYSQL Presentation for SQL database connectivity
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...

C++ question and answers

  • 1. 1. What is computer? ANS: A computer is a device that can be instructed to carry out sequences of arithmetic or logical operations automatically via computer programming. 2. What is computer program? ANS: A computer program is a set of instructions for a computer to follow 3. What is Computer software? ANS: Computer software is the collection of programs used by a computer 4. Discuss Computer Vs Human? ANS: Computers understand a language variously known as computer language or machine language.  Therefore, computers and humans have agreed to sort of meet in the middle, using intermediate languages • Humans can speak C++ (sort of), and C++ is converted into machine language for the computer to understand 5. What is Compilers? ANS: Translate high-level language to machine language 6. What is source code? ANS: Sourcecode: the original program in a high level language 7. What is object code? ANS: the translated version in machine language • Object code is also referred to as binary code or machine code 8. What is Linker? • ANS: A Linker combines • The object code for the programs we write and • The object code for the pre-compiled routines into The machine language program the CPU can run. 9. Why Do We Need Object-Oriented Programming? ANS: Object-oriented programming was developed because limitations were discovered in earlier approaches to programming. To appreciate what OOP does, we need to understand what these limitations are and how they arose from traditional programming languages. 10. What is procedural language? ANS: C, Pascal, and similar languages are procedural languages. That is, each statement in the language tells the computer to do something. 11. What is class? ANS: A class is a description of a number of similar objects. 12. What is instance of class? Chapter 1: Object Oriented Programming in C++
  • 2. ANS: specific people with specific names are members of this class if they possess certain characteristics. An object is often called an “instance” of a class. 13. What are oo p characteristics? 14. What are the benefits of oop? ANS: 15. What is Algorithm?  ANS: Algorithms ◦ A sequence of precise instructions which leads to a solution  Program ◦ An algorithm expressed in a language the computer can understand 16. How many types the problem solving in c++? ANS: Problem Solving Phase Implementation Phase 17. What is Problem solving Phase? Develop the algorithm before implementation 18. What is implementation Phase? ANS: Translate the algorithm into a programming language 19. What are the three errors of programming language?
  • 3.  Syntaxerrors  Run-time errors  Logicerrors END Chapter1 20. What is Function?  ANS: Functions are one of the fundamental building blocks of C++. The FIRST program consists almost entirely of a single function called main ( ). 21. What is comment? ANS: Comments help the person writing a program, and anyone else who must read the source file, understand what’s going on. 22. Two types of comment?  ANS: Single-line comment which begins with // and terminates at the end of the current line.  Multi-line comment which begins with /* and ends with */. 23. What is Variable?  ANS: A variable is a location in the computer's memory where a value can be stored for use by a program.  All variables must be declared with a name and a data type before they can be used in a program  Declarations of variables can be placed almost anywhere in a program  That value is actually placed in the memory space assigned to the variable. Chapter2 C++Programming Basics
  • 4. 24. Tell the Basic Data base 25. Tell Their Basic Range 26. What is difference B/wee Expressions and Statements? ANS: Any arrangement of variables, constants, and operators that specifies a computation is called an expression. Statements tell the compiler to do something and terminate with a semicolon. 27 Tell the rules of operator precedence? ANS: PEDMAS (Parentheses, Exponents, Division, Multiplication, Addition and Subtraction) END Chapter2
  • 5. Q1: what is called operator that compares two values? A1: A relational operator. Q2: what do loops cause? A2: Loops cause section of your program to be repeated a certain number of times. Q3: what are three kinds of loops in C++? • A3:There are three kinds of loops in C++: • the for loop • the while loop • and the do loop Q4: what is for loop? A4: The for loop executes a section of code a fixed number of times. Q5: when for loop used? A5:It’s usually used when you know, before entering the loop, how many times you want to execute the code. Q6: when while loop used? A6: The while loop is used when you do not know how many times you want to do something before you start the loop. Q7: when test of while loop is evaluated? A7: The test expression is evaluated at the beginning of the loop. Q8: which have higher precedence arithmetic and rational operators? A8: Note that arithmetic operators have a higher precedence than relational operators Example (a < b / 2) Q8: when do loop used? A8: Use do loop when you want to guarantee that the loop body is executed at least once. Chapter3 C++Programming Loops
  • 6. Q9: when test of do while is evaluated? A9: The test expression is evaluated at the end of the loop. Q10: what do break and continue statement are used? A10: break and continue statements are used to alter the flow of loops. Q11: what are three types of decisions? A11:  The if statement  The if...else statement  Nested if...else statement  The switch statement Q12: what does if statement performs? A12: The if statement performs an action if a condition is true or skips the action if the condition is false. END Chapter3 Q1. Define function? And tell the most important reason to use functions? A1. A function groups a number of program statements into a unit and gives it a name. The most important reason to use functions is to: Chapter4 C++ Programming Function
  • 7. • Divide a program into units (divide & conquer). • Reduce program size: the function’s code is stored in only one place in memory, even though the function is executed many times. Q2.What is the three components necessary to add a function to a program? A2.The three components necessary to add a function to a program are: a. the function declaration b. the calls to the function c. And the function definition. Q3.Distinguish the different b/w function declaration, calling and function Definition? A3. Function Declaration  Declare the function before it is called  Notice that the function declaration is terminated with a semicolon.  Function declarations are also called prototypes, since they provide a model or blueprint for the function.  The keyword void specifies that the function has no return value, and the empty parentheses indicate that it takes no arguments Function calling • To call a function we need: the function name, followed by parentheses. • The syntax of the call is very similar to that of the declaration, except that the return type is not used. • The call is terminated by a semicolon. Function definition • The definition contains the actual code for the function. • The definition consists of a line called the declarator, followed by the function body.
  • 8. • The declarator must agree with the declaration: It must use the same function name, have the same argument types in the same order (if there are arguments), and have the same return type. • Notice that the declarator is not terminated by a semicolon. Q4.Define declaration and tell some library functions? A4.The declaration is in the header file specified at the beginning of the program (conio.h for getche () and cmath.h for sqrt()). Some library function such as getche () or sqrt ()? Q5.What is an argument and parameters? • An argument is a piece of data passed from a program to the function. • Arguments allow a function to operate with different values, or even to do different things, depending on the requirements of the program calling it. The variables used within the function to hold the argument values are called parameters. Q6. What is the different b/w passing by value and passing by reference? A6.Passing by value • Passing by value means that the function creates copies of the arguments passed to it. The called function creates a new variable of the same type as the argument and copies the argument’s value into it. • The function cannot access the original variable in the calling program, only the copy it created. • Passing arguments by value is useful when the function does not need to modify the original variable in the calling program. • In fact, it offers insurance that the function cannot harm the original variable. Passing by reference
  • 9. • In passing arguments by reference, a reference to the original variable, in the calling program, is passed. (It is actually the memory address of the variable that is passed). • An important advantage of passing by reference is that:  The function can access the actual variables in the calling program.  It provides a mechanism for passing more than one value from the function back to the calling program. Q7.Describe Overloaded Functions with example? A7.An overloaded function performs different activities depending on the kind of data sent to it. It is more convenient to use functions with the same name even though they each have different arguments. Examples • Declaration: Voiddrawchar (); Voiddrawchar (char); Voiddrawchar (char, int); • Calling: Draw char (); Draw char ('='); Draw char ('+', 30); Q8.What is Recursion? A8.Recursion involves a function calling itself. Recursion is much easier to understand with an example than with lengthy explanations.
  • 10. Q9. What is Default Arguments? A9.A function can be called without specifying all its arguments. • The default argument follows an equal sign, which is placed directly after the type name. • Remember that missing arguments must be the trailing arguments—those at the end of the argument list. Q10. Differentiate Scope and Storage Class? A10.scope • The scope of a variable determines which parts of the program can access it, and its storage class determines how long it stays in existence. • Two different kinds of scope are important here: local and file.  Variables with local scope are visible only within a block.  Variables with file scope are visible throughout a file. Storage Class • A block is basically the code between an opening brace and a closing brace. Thus a function body is a block. • There are two storage classes: automatic and static. • Variables with storage class automatic exist during the lifetime of the function in which they are defined. • Variables with storage class static exist for the lifetime of the program. END Chapter4