A. does not vary with compiler.
B. vary with each processor type & implementation of C++ compiler.
C. varies with processor.
D. various with interpretrator.
Data types are means to identify the type of data and associated operations of handling it. its size and range vary with processor and c++compiler.
A. integer code.
B. float code.
C. decimal code.
D. hexadecimal code.
Letters,symbols etc are characters and are represented in memory by number codes.
A. 215
B. 250
C. 256
D. 253
Characters refer to letters, digits, symbls, nongraphic characters etc. ASCII codes stores number codes for 256 known characters.
A. integer.
B. character.
C. string.
D. float.
Data can be of many types, any data that is enclosed in double quotes represents a string.
A. letters.
B. symbols.
C. digits.
D. all of above
letters, digits, symbols and nongraphic characters etc. together form characters.
A. polymorphism.
B. type of data.
C. operations.
D. type of data & operations.
Data types are means to identify the type of data and associated operations of handling it.
A. printf( ).
B. setw( ).
C. cout.
D. cin.
Output can be formatted by manipulators, setw( ) is one of the manipulator offered by C++.
A. int.
B. structure.
C. void.
D. char.
User defined data type are the data types that are derived from fundamental data types(i.e int, char, float, double and void).
A. int.
B. void.
C. char.
D. reference.
Build in data type are the data types that are derived from fundamental data types(i.e int, char, float, double and void).
A. memory address.
B. data value of the variable.
C. variable’s name.
D. both a and b.
A variable has two associated values: (1) rvalue: which is data value. (2) lvalue: which is location value or memory address.
A. integer
B. float
C. char
D. void
The void type specifies an empty set of values. It is used as the return type for functions that do not return a value.
A. signed and unsigned.
B. long.
C. short.
D. all of the above
modifiers are used to alter the meaning of the base type. The list of modifiers are: (1) signed (2) unsigned (3) long (4) short
A. any member of c++ basic character set.
B. character value is equivalent to the integer code of that character.
C. an identifier declared as char becomes a character variable.
D. all of the above.
The char type is really another integer type. It represent the basic character set (letters, digits, punctuation etc.)
An array is a collection of variables of the same type that are referenced by a common name.
There are two types of arrays -
(i) Single-Dimensional Array - An array with only one dimension and comprised of finite homogeneous elements.
(ii) Multi-Dimensional Array - An array with more than one dimension where each element is itself an array. Two-dimensional array is one of the simplest form of multi-dimensional array.
An array of strings is a two-dimensional character array. The size of first index(rows) determines the number of strings and the size of second index(columns) determines maximum length of each string.
The following code declares an array of 10 strings, each of which can hold maximum 15 valid characters -
char strings[10][15];
The formula to be used here is -
Total bytes=sizeof (base-type) * size of the array
Therefore the total number of bytes will be,
= 4 * 10
= 40 bytes
void main()
{
int i,j,n=5;
int sum=0;int x[5][5];
for(i=0;i< n;i++)
for(j=0;j< n;j++)
cin >>x[i][j];
if(i==j)
sum=sum+x[i][j];
cout<<"Sum of the diagonal elements of the matrix is ="<
C++ provides the facility to skip the size of an array at the time of initialization. In such
cases, C++ automatically calculates the size of the array on the basis of its type and dimension.
Some Example of unsized array are -
(i)
(ii) char S[ ]= "the string is"
(iii) int cube[ ][2]
In C++ it is represented as
X=[x1,x2,x3,……xn]
C++ provides the facility of array initialization at the time of declaration. The arrays are initialized in the same way as other variables are. The general form of array initialization is as shown below -
type array-name[size 1].....[size N] = {value list};
In sized array initialization we mention the size of the array. For Ex -
int A[5] = {2,4,3,78,31};
In unsized array initialization we can skip the size of the array. Here compiler automatically calculates the size of the array. For Ex-
int A[ ] = {2,4,3,78,31};
A character array requires 1 byte for each character. In the same way an integer array requires 2 bytes to store each element of the array.
The amount of storage required to hold an array is directly related to its type and size.
A two-dimensional array is the simplest form of multi-dimensional array in which each element is an array. The general form of a two-dimensional array declaration is as follows -
type array-name[rows] [columns];
Example -
int sales[5][12];
Program to read sales of 5 salesmen in 12 months and to print total sales made by each salesman -
#include < iostream.h>
#include < conio.h>
void main()
{
clrscr();
int sales[5][12];
int i,j,total;
for(i=0;i<5;i++)
{
total = 0;
cout<<" n Enter sales for salesman"<
for(j=0;j<12;j++)
{
cout<<"Month"<
cin>>sales[i][j];
total=total + sales[i][j];
}
cout<<"n";
cout<<"Total sales of salesman"<
}
getch();
}
A single-dimensional array is an array of only one dimension. The general form of declaration of a single-dimensional array is -
type array-name[size];
where,
type - specifies the base-type or data-type of the array
array-name - specifies the name of the array
size - specifies the total number of elements of the array.
Example - int A[10];
The above statement declares a single-dimension array A which can hold 10 integer type variables.
A two-dimensional array is an array in which each element is itself an array. The syntax to declare a two-dimensional array is -
type array-name[row-size][column-size];
where,
type - specifies the base-type or data-type of the array
array-name - specifies the name of the array
row-size - specifies the number of rows
column-size - specifies the number of columns
Example - int A[3][3];
The above statement declares a two-dimensional array "A" which can hold 9 integer type variables in the form of rows and columns.
A. A reference can be used without proper initialization.
B. Array of references is legal in c++.
C. Char, int pointers can refer to null pointers but null pointers cannot refer to other pointers.
D. Array of pointers is not legal in c++.
A reference has to be properly initialized, otherwise it will result in an error. In C++ , special care is taken for assignment of void pointers to other pointer types. While, we can assign a pointer of any type to a void pointer but, the reverse is not true until, we do explicit typecasting.
A. this would give an error as no union name defined.
B. It would give output null.
C. the code is correct and legal in C++.
D. The code is correct and legal in C and C++.
The code is legal in C++ but not in C. Unions, which do not have a class name, they are anonymous union.
A. pointer cannot be used in assignment statement.
B. ip is a pointer and cannot be used as an integer.
C. pointer should not be initialized.
D. pointer can not be equal to zero.
A pointer points to the address of a variable. It cannot be used as integers.
A. print this is end.
B. print hello one time.
C. compiler error.
D. run time error.
It will print this is end because if condition is wrong hence the else part is executed.
A. structure.
B. struct.
C. define.
D. tag.
A structure is declared using keyword struct. Example
struct names
{ int class;
int rollno;
float marks;
char grade;
};
A. -0.00625.
B. 35.66.
C. + 5.0.
D. 15,356.30.
Basic real constant is an optional sign, an integer part, a decimal point and a fractional part. Commas(,) are not allowed in real constant.
A. setw.
B. setiosflags.
C. setprecision.
D. endl.
The setw( ) manipulator sets the width of the field assigned for output. It takes the size of the field as a parameter.
A. same as 'n'.
B. to send a newline character 'n' and then, flush the output buffer.
C. it flushes the output buffer.
D. to send a newline character 'n' but, does not flush the output buffer.
'n' and endl manipulator sends a new line character 'n', but endl also flushes the output buffer whereas, 'n' does not flush the output buffer.
A.
B.
C.
D.
While declaring an array we declare its type,name and size. The syntax of declaring an array is type name[size];
A. variable.
B. vector.
C. row itself .
D. column itself.
A matrix with one row(column) may be viewed as a vector and similarly, a vector may be viewed as a matrix with one row(column).
sizeof(base type) * size of array
number_of_columns
sizeof(base type).
A multi dimensional array is an array which comprises of many elements each of which is itself an array. A multi-dimensional arrays are the arrays of more than one dimension.
The following statement will declare a string "chemical" and initialize it with the value “CH6H2O6H20” -
char chemical[20]="CH6H2O6H2O";
An array element is accessed by its array name and index number.
The element numbers within [ ] are called subscripts or indices. It specifies the position of the elements in an array and it cannot be negative.
The above mentioned code segment will calculate the sum of the following matrix
5 4 3
8 2 7
5 2 1
and displays the sum as 37.
A matrix is a mathematical tool. It is a set of mn numbers arranged in the form of a rectangular array of m rows and n columns.
The elements which are available at the diagonal of a matrix are known as diagonal elements.
The diagonal elements of the matrix A are
1, 5 and 9.
b) int digit={3,5,6,9,1};
The (i) and (ii) statements are valid whereas the (iii) statement is invalid as the size of an array cannot be defined as 0-10.
The correct form is -
int num[11];
matrix A matrix B result matrix c
1 2 3 9 8 7 10 10 10
4 5 6 6 5 4 10 10 10
7 8 9 3 2 1 10 10 10
C[i][j]=A[i][j] + B[i][j]
A. Reserved words.
B. Modifiers.
C. Identifiers.
D. variable.
modifiers are used to alter the meaning of the base type. The list of modifiers are: (1) signed (2) unsigned (3) long (4) short
A. Uninitialized.
B. Initialized.
C. Dynamically Initialized.
D. All of the above.
In C++, a variable can be declared in three ways: (1) Uninitialized variable e.g. int val; (2) Initialized variable e.g. int val =5; (3) Dynamically initialized variable e.g. int val = b*c;
A. integer constant.
B. float constant.
C. long integer constant.
D. double.
An l or L suffix indicates it is long integer conatant. Thus 35L is a long integer constant.
A. reference to reference.
B. no references to references.
C. partial reference to reference.
D. none of the above.
According to rules of reference, there can be no references to reference, no arrays of reference, and no pointers to reference.
A. Float.
B. Double.
C. Long double.
D. All of the above.
All the above three are float types, float contain 4 byte, double contain 8 byte, long double contain 10 byte.
A. three.
B. two.
C. five.
D. one.
C++ offers two types of two types of data types: (1) Fundamental data types. (2) Derived data types.
A. two parts.
B. four parts.
C. six parts.
D. eight parts.
There are four integer types: (1) char (2) int (3) short (4) long
A. a float identifier.
B. an int identifier.
C. no identifier.
D. none of the above.
Identifier identify the type of data that a variable must hold, for floating point data we use float identifier.
A. + symbol.
B.
C. * symbol.
D. / symbol
Pointeris a variable that holds a memory address. A pointer declaration consists of a base type, an *(asterisk), and the variable name. e.g. type *ptr;
A.
B. Store real numbers.
C. Do not have a fractional part.
D. Are fractional signed numbers.
Integer data types are used to store integer values and has no concerned with fractional part.
A. Reference.
B. Int.
C. Void.
D. Char.
Derived data type are derived from fundamental data types(int , char, float, double, and void).
A. base type, &(ampersand) and reference variable name.
B. base type, *(asterisk) and reference variable name.
C. base type, and reference variable name.
D. *(asterisk) and reference variable name.
A reference variable proviodes an alias for a previously defined variable. A reference declaration consist of
base type, &(ampersand) and reference variable name. e.g. type & ref_var = variable name;
A. one byte.
B. Two bytes.
C. Four bytes.
D. Three bytes.
The data type short takes two bytes of storage in the memory. It is also used to store integer values.
A. short.
B. int.
C. long.
D. arrays.
Derived datatype can be derived from fundamental datatype. Arrays is one of the derived data type.
A. only empty set of values.
B. only for non returning functions.
C. only functions.
D. for empty set of values & non returning functions.
The void type specifies an empty set of values. It is used as the return type for the functions that do not return a value.
A. fractional numbers.
B. numbers without decimal value.
C. signed integers and unsigned integers.
D. single integer.
float and double float used to represent fractional-point number.
A. sets of total number of digits of decimal places to be displayed.
B. sets the number of decimal places
C. will round off numbers.
D. all of the above.
The setprecision function can be used to set the maximum number of digits that are displayed for a number along with rounding off.
A. when writing the program.
B. when the program is running.
C. while editing the program.
D. while compiling the program.
Dynamic initialization is the initialization done at run time.
A. r value.
B. l value.
C. l +r values.
D. l - r value.
l value is the location value. It gives the address in memory at which its data value is stored.
A. long data type.
B. short data type.
C. double data type.
D. char data type.
Data type double holds twice as large memory with larger range and precision.
A. iostream.h
B. iomanip.h
C. conio.h
D. stdio.h
In order to use the manipulators, you must include header file iomanip.h in your program.
A. one.
B. two.
C. three.
D. four.
A variable has two associated values: (1) rvalue, which is its data value. (2) lvalue, which is its location value.
A. implement dependent.
B. not implement dependent.
C. array independent.
D. structures dependent.
Characters are implement dependent. A character represents any letter, digit, special symbols and white spaces.
A. *a
B. a
C. &a
D. address(a)
The operator & is used to find the address, associated with a variable. The syntax of the reference operator is as follows: & variablename.
A. int x;
B. int &x;
C. ptr x;
D. int *x;
In order to define pointer variables, the programmer must use the operator '*' before variable.
A. //
B. {
C. ;
D. *
C++ supports two types of comments: // for single line comments and /* */ for block of code or multiple line.
A. has more than a name.
B. has no member functions.
C. is just a name.
D. has no common properties.
A empty class has no variable declarations, no functions or methods but the objects of these classes can have non–zero size.
A. data, rather than the work performed on it.
B. doing things, rather than data itself.
C. objects and classes.
D. principles of data hiding, abstraction and encapsulation.
Procedural programming aims at procedures. It is a list of instructions telling a computer, step by step, what to do, usually having a linear order of execution, from the first statement to the last.
A. free( ) operator.
B. delete( ) operator.
C. clear( ) operator.
D. remove( ) operator.
The delete operator( )deallocates a block of memory. The argument must be a pointer to a block of memory previously allocated for an object, created with the new operator. The delete operator has a result of type void and therefore, does not return a value.
A. new( ).
B. malloc( ).
C. create( ).
D. value( ).
The new keyword allocates memory for an object, or array of objects of type-name from the free store and returns a suitably typed, non-zero pointer to the object.
A. a;
B. val(a);
C. *a;
D. &a;
* is value at address operator. Thus, it displays the value pointed by pointer a.
A. two operands.
B. no operand.
C. one operand.
D. any number of operands.
C++ provides two unary arithmetic operators-unary plus and unary minus. Unary operators operate on only one operand, which could be a constant or a variable.
A. an identifier can start with the "_".
B. an identifier can begin with a digit.
C. that all special characters are allowed in c++ identifiers.
D. that single character constants have type char.
Identifiers can start with "_", but not digits. Identifier is an arbitrarily long sequence of letters and digits. Upper and lower case are different. Single character constants have type int.
A. an integer.
B. a character constant.
C. a hexadecimal integer constant.
D. an integer constant.
Invariant program elements are called "literals" or "constants." The terms "literal" and "constant" are used interchangeably here. OxFE is an integer constant.
A. escape sequence for start.
B. escape sequence for end.
C. escape sequence for null.
D. escape sequence for new line.
'n' sends the new line character, so it is a escape sequence for new line.
A. within square brackets.
B. within angular bracket.
C. within curly braces.
D. without any bracket.
Every function in c++ has its code within curly braces { }
A. declare-define-use.
B. public functions and private variables.
C. top down programming.
D. bottom up programming.
Object oriented systems use bottom up approach. It uses concept of objects and classes.The execution would be bottom up approach because the main function is in the bottom.
A. can have elements of different data type.
B. always has elements of the same data type.
C. will have elements of the same struct type.
D. can also define a structure within it.
Arrays refer to a named list of a finite number n of similar data elements.
A. one.
B. two.
C. three.
D. four.
C++ offers two types of data types: (1)Fundamental data types (2)Derived data types
A. conio.h
B. iostream.h
C. stdio.h
D. iomanip.h
The header file iostream.h contains 2 files : istream and ostream. These have libraries of code, which we may insert in the program, by using as a reference in the top block.
A. integers.
B. floating point numbers.
C. integers and floating point numbers.
D. characters.
Vectors in C++ consists of only integers and floating-point numbers.They can be resized during the execution of the program.
A. logical operators.
B. relational operators.
C. conditional operators.
D. arithmetic operators.
Logical operators are (&&,||,!) , arithmetic operators are (+,-,*,/,%),and Relational operator is (==, <=, >=).
A. can not be used.
B. may/may not be used.
C. can be used.
D. can only be used.
Keywords are reserved words. They cannot be used as identifier names. It is illegal in C++.
A. real constant.
B. integer constants.
C. char constant.
D. binary constants.
A "floating constant" is a decimal number that represents a signed real number. The representation of a signed real number includes an integer portion, a fractional portion, and an exponent. Use floating constants to represent floating-point values that cannot be changed.
A. symbolic.
B. basic.
C. simple.
D. atomic.
Fundamental (atomic) data types are those that are not composed of other data types. The five fundamental data types are : int data type, char data type, float data type, double data type and void data type.
A. a programmer.
B. a compiler.
C. a preprocessor.
D. an interpreter.
There are 2 types of conversions available in C++ i.e. implicit and explicit conversions. Implicit conversions are performed by compilers in those expressions, which have mixed data types.
A. type of data only.
B. type of data & associated operations for handling it.
C. operations for handling data only.
D. data, operations and memory allocations.