C++ Question and Answers
C++ Question and Answers
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: C, Pascal, and similar languages are procedural languages. That is, each
statement in the language tells the computer to do something.
END Chapter1
Chapter2 C++ Programming
END Chapter2
A2: Loops cause section of your program to be repeated a certain number of times.
A4: The for loop executes a section of code a fixed number of times.
A5:It’s usually used when you know, before entering the loop, how many times you
want to execute the code.
A6: The while loop is used when you do not know how many times you want to do
something before you start the loop.
A8: Note that arithmetic operators have a higher precedence than relational
operators
Example (a < b / 2)
A8: Use do loop when you want to guarantee that the loop body is executed at least
once.
A10: break and continue statements are used to alter the flow of loops.
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
Chapter4 C++ Programming Function
Q1. Define function? And tell the most important reason to use
functions?
Function calling
Function definition
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.
Passing by reference
Examples
• Declaration:
Voiddrawchar ();
Voiddrawchar (char);
• Calling:
Q8.What is Recursion?
A10.scope
Storage Class
• Variables with storage class static exist for the lifetime of the
program.
END Chapter4