Computer Basics (C++)
A comprehensive test covering fundamental C++ programming concepts including classes, arrays, pointers, operators, control structures, data structures, and language features.
Questions
In C++, a function contained within a class is called ______.
- a member function
- a class
- an operator
- a data item
The break statement causes an exit ______.
- only from the innermost loop
- only from the innermost switch
- from all loops and switches
- from the innermost loop or switch
The && and || operators ____.
- compare two numeric values
- combine two numeric values
- compare two Boolean values
- combine two Boolean values
An array element is accessed using _______.
- the first-in first-out approach
- the dot operator
- a member name
- an index number
The function toascii() is declared in the header file _________.
- stdio.h
- math.h
- ctype.h
- string.h
Which of the following functions is used to input data from keyboard?
- cout
- cin
- cerr
- get
A stack is a linear data structure in which data is stored and retrieved in a _______.
- <>
- ##
- !=
- :=
A stack is a linear data structure in which data is stored and retrieved in a _____.
- Last Out First In (LOFI)
- Last In First Out (LIFO)
- First In First Out (FIFO)
- Last In Last Out (LILO)
Which of the following statements is the terminator in C++?
- ;
- ,
- :
- /
The keyword 'void' is used to _____.
- declare a member function that is defined in a subclass
- designate the absence of a type
- declare objects that can be modified outside of program control
- declare a synonym for an existing type
In C++, 'while' is a/an __________ control structure.
- sequential
- count
- repetitive
- incremental
When a multi-dimensional array is accessed, each array index is ________.
- separated by commas
- surrounded by brackets and separated by commas
- separated by commas and surrounded by brackets
- surrounded by brackets
Operator Overloading is _____.
- Making C+ operators work with objects
- Giving C++ operators more than they can handle
- Giving new meanings to existing C++ operators
- Making new C++ operators
On which of the following languages is C++ based?
- FORTRAN
- PASCAL
- C
- JAVA
Which of the following characters is known as a newline character?
- r
- d
- l
- c
What will be the output of the under given program?
#include<iosteam.h>
void main()
{
int k;
cout<<”k=”<<k;
}
- An error
- Unpredictable
- 567
- 0
Who developed C++?
- Dennis Ritchie
- Bjarne Stroustrup
- Blaise Pascal
- John Von Neuman
Which of the following operators is used for modulus or remainder?
- /
- //
- %
- %%
A pointer is _____.
- the address of a variable
- an indication of the variable to be accessed next
- a variable for storing addresses
- the data type of an address variable
What error would the following function give on compilation?
f(int a, int b)
{
int a;
a=20;
return a;
}
- Missing parentheses in return statement.
- The function should be defined as int f(int a, int b).
- Redeclaration of 'a'.
- None of the above
The 'goto statement' causes control to go to _____.
- an operator
- a label
- a variable
- a function
What will be the output of the given program?
#include<iostream.h>
void main ( )
{
int a=5;
cout<< ++a;
}
- 6
- 5
- 4
- 0
The library function exit ( ) causes an exit from _____.
- the loop in which it occurs
- the block in which it occurs
- the function in which it occurs
- the program in which it occurs
What will be the output of the given program?
#include<iostream.h>
void main ( )
{
int a=1;
for(;;)
{
cout<< a++;
if(a>10)
break;
}
}
- The condition in the for loop is must.
- The two semicolons should be dropped.
- The for loop should be replaced by a while loop.
- No error
What will be the output of the given program?
#include<iostream.h>
void main ( )
{
cout<< 5+ “Hello world”;
}
- Error
- Hello
- World
- None of the above