Revision Questions For C++
Revision Questions For C++
C++ - Introduction
Answer the following questions:
Ans: A variable definition tells the compiler where and how much storage
type variable_list;
int i, j, k;
char c, ch;
float f, salary;
double d;
Ans: Constants are like a variable, except that their value never changes during execution once
defined.
Declaration of a constant :
Syntax:
const [data_type] [constant_name]=[value];
Ans: Keywords are reserved words which have fixed meaning, and its meaning cannot be changed.
C++ has more keywords than C, and those extra ones have special working capabilities.
Ans: C++ operator is a symbol that is used to perform mathematical or logical manipulations.
● Arithmetic Operators
● Relational Operators
● Logical Operators
● Bitwise Operators
● Assignment Operators
● Misc Operators
/ Divide operator
Divides numerator by
Denominator . Give quotient as a result.
Eg. Int A=2,B=4;
B / A will give 2
6. What is a namespace?
Ans: A namespace is designed to overcome this difficulty and is used as additional
information to differentiate similar functions, classes, variables etc. with the same name
available in different libraries. Using namespace, you can define the context in which names
are defined. In essence, a namespace defines a scope.
A namespace definition begins with the keyword namespace followed by the namespace
name as follows −
namespace namespace_name {
// code declarations
}
To call the namespace-enabled version of either function or variable, prepend (::) the
namespace name as follows −
name::code; // code could be variable or function.
************