Você está na página 1de 3

What is the difference between prefix and postfix increment operator? Ans.

The main difference between prefix and postfix increment operator lies in the mode of their working. The prefix increment operator first increases the value by one and then uses the increased value. In case of post increment operator, the current value of the operator is used and after this, the value is incremented by one. What do you mean by a preprocessor directive? Ans. A preprocessor is a program that manipulates the source program before this program is passed to C++ compiler. A preprocessor directive is used to instruct the preprocessor to perform a specific action in the source program before its implementation. The preprocessor directives also known as processor commands. In C++ following are main directives. #define, #include, #undef, Each preprocessor directive begins with a special point sign #. What do you mean by an identifier? How it is different from keyword? Ans. An identifier is a name given to a variable, function, array, structure, class and label in C++ program. Identifiers are created by declaring them in the declaration section. Keywords are special words whose meaning is fixed by the language. You can use these keywords but can not alter them. Keywords are also called reserved words. What is an abstract data type? Can we declare a class as an abstract class? Ans. The data type created by user which hide the internal details of object is called abstract data type. What do you mean by local and Global variable? Ans. Local variable: A local variable is a variable defined within the function. The local variable name and value is known to function within which the variable is declared. Global variables are those variables which are known throughout the entire program. To declare global variable place the declaration at the start of program, outside of any function. Eg int global; void main() { //program statements; }

What do you mean by conversion or type conversion?

Ans. Type conversion: Since we know that data may be of different type: characters, integers, floats and so on. Each has different range of values because of their size and their signed and unsigned properties. In practical applications an expression can have an operation between two different data types, say one can be an integer and another can be a float or vice versa. To handle such situations, C++ provides certain rules of type conversion in these cases. When Compiler encounters different types of operands in the same expression the smaller type variable is promoted to larger type variable. For example if you assign a variable of smaller type, say an int to a larger type, say a float then the (int) smaller value us promoted to larger value (float), however if you assign a value of larger type say afloat to smaller type, say an int then the large value is demoted and it can even truncate the excess data or in some case compilers warn you, unless you simplicity cast it. What do you mean by btype casting? Explain by giving suitable example. Ans. Type Casting. As opposed to the automatic type conversions, C++ provide type casting. The casting is technique by which you can convert one type to another type explicitly. Type casting in C++ is performed as type(expression); Type(expression); Here type is any valid data type in C++ to which the conversion is to be performed. Consider the following Example: #include<iostream.h> Void main() { Int x; Float y; X=1000; Y=x/3; Cout<< \n y= <<y; Y=float(x)/3; Cout<< \n y= <<y; } When you execute this program, you get the following output: Y =333 Y =333.333344.

Explain input and output statement in C++. Ans: The cin and cout statements are input and output statements in C++ respectively. (page 23) What do you mean by cascading. Ans. C++ provides the facility to cascade the extraction and insertion operator (<< and >> resp) repeatedly in order to receiving series of data values or display a series of data values respectively. Thus following statements Cin>>a; Cin>>b; Can be written as Cin>>a>>b;

Você também pode gostar