20 C++ Question-Answer (Part – 1) with Free Notes

1. Question : What are the Comments in C++ ???

Each and Every language will provide this great feature which is used to document source code. We can create more readable and eye catching program structure using comments. We should use as many as comments in C++ program. Comment is non executable Statement in C++.

2. Question : Types of Comments in C++ ???

We can have two types of comment in Programming: –

  1. Single Line Comment
  2. Multiple Line Comment

3. Question : What are Character Set???

Character Set is the combination of alphabets or characters, digits, special symbols and white spaces as same as learning English is to first learns the alphabets, then learn to combine these alphabets to form words, which in turn are combined to form sentences and sentences are combined to form paragraphs. More about a C++ Program we can say that it is a sequence of characters.

C++ Free Hand-Written Notes

4. Question : What are Variables ?

Variables are names as like keywords which are used for reserving memory to hold some data so that we don’t have need to remember the numbers of memory locations/address like 46735 and instead we can use the memory location by simply referring to the variable name. Every variable have a unique memory address. For example if we have 3 variables naming v1, v2, v3. They may be assigned the memory addresses 32000, 12456, 6783 respectively. Variables name follow same naming convention as of identifier.

5. Question : What are Local and Global Variable ???

  • Local variable: – A variable which is declare in any scope is called local variable. We cannot use these variable outside the scope.
  • Global Variable: – C++ allows you to declare a variable outside of any function. Such as variable id referred to as a global variable.

6. Question : Explain Namespace.

A namespace is as like a container which can hold a logical grouping of unique identifiers or symbols, that’s why some times its called an abstract container or environment. Namespace is also called a nape scope. An identifier defined in a namespace is associated only with that namespace. The same identifier can be independently defined in multiple namespaces. That is, the meaning associated with an identifier defined in one name space may or may not have the same meaning as the same identifier defined in another namespaces. A namespaces can contain group entities like classes, objects, and functions under a name.

7. Question : Explain Classes with Syntax.

Class is powerful feature of oops. It is a heterogeneous structure, means we combined different values with different types. It is a collection of properties and methods. Its syntax is:

class <class name>
  {
   Access modifiers:
   Member variable
   Member function 
  };

access modifiers is used to giving the accessing scope to member function and member variable. The variable which are declare in a class is called member variable and function declare in a class is called member function.

8. Question : Explain Operators?

An Operator is a symbol which is used by user for giving instruction to computer for doing a certain mathematical or logical manipulations on one or more operands. Operands is the quantity on which an operation is to be performed For Example:

3+6 = 9

9. Question : Explain Mixed Mode Arithmetic in C++??

When one of the operand is real and other is an integer and if the arithmetic operation is carried out on these 2 operands then it is called as mixed mode arithmetic. For Example:

4 + 3.5 = 7.5

10. Question : Explain Unary Operators.

The classes of operator that act upon a single operand to produce a new value as known as Unary Operator. The frequently used Unary Operators in C++ are

  • Unary Minus
  • Increment and Decrement Operator
  • sizeof Operator
  • Cast Operator

11. Question : Explain Compound Statements.

Is also called Statement Blocks. A compound statement is a sequence of reserved words that continue expressions and statements into a logical group that performs a specific task. A statement block is two or more statements enclosed in braces { }.

12. Question : Explain Control Statement.

The control statements are used for controlling the flow of program. Control statements basically used to check the condition and change the flow of program according to there result. The Keyword of the control statement are predefined.

if(a>b)
{
  ---
}

13. Question : How many types of Control Statements in C++ ?

In C++ three types of Control Statement are present,

  1. Decision Control Statements
  2. Loop Control Statements
  3. Jumping Statements

14. Question : What is Decision Control Statement in C++?

It is also called a Conditional Expression. The decision control statements basically used for taking decision based on any expression. C++ has a number of statements for this purpose. The Following statements use to perform the task of conditional statements.

  1. If Statement
  2. Switch Case Statement

15. Question : What is Loops ?

Loops are used to repeat a block of code. If we want to execute a block in our program more then one time then we use loop. In Other Words, if we want to print same result 10 times than we write this statement 10 times and so on. The Better Solution of this problem is loop.

16. Question : What is Jumping Statement and it’s types ?

If we want to jump one location to another location in the program based on any condition then we use jumping statement. In C++, we use following jumping statements,

  1. Goto Statement
  2. Break Statement
  3. Continue Statement

17. Question : What is Break Statement?

Using break we can breakdown a loop even if the condition for its end is not fulfilled. For example, we are going to stop the count down before its natural end.

18. Question : What is Continue Statement?

The continue statement is use to skip the continuity of the loop in the current iteration as if the end of the statement block has been reached, causing it to jump to the start of the following iteration.

19. Question : What is GoTo Statement?

Goto Statement is used to jump the other location of a program without checking any condition that’s why it is called unconditional statement. In this statement we use labels (label is a name ending with statement colon(:) sign).

20. Question : What is Entry and Exit Loop in C++?

  • Entry Loop: – A loop in which first we check the expression then the body of the loop is execute is called entry control loop. In this type C++ have two types of loop : For Loop and while Loop
  • Exit Loop: – A Loop in which the body of the loop is execute before checking the expression is called exit control loop. C++ Provide a single exit control loop: do-while loop.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top