Computer Basics (C++)

A comprehensive test covering fundamental C++ programming concepts including classes, arrays, pointers, operators, control structures, data structures, and language features.

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

In C++, a function contained within a class is called ______.

  1. a member function
  2. a class
  3. an operator
  4. a data item
Question 2 Multiple Choice (Single Answer)

The break statement causes an exit ______.

  1. only from the innermost loop
  2. only from the innermost switch
  3. from all loops and switches
  4. from the innermost loop or switch
Question 3 Multiple Choice (Single Answer)

The && and || operators ____.

  1. compare two numeric values
  2. combine two numeric values
  3. compare two Boolean values
  4. combine two Boolean values
Question 4 Multiple Choice (Single Answer)

An array element is accessed using _______.

  1. the first-in first-out approach
  2. the dot operator
  3. a member name
  4. an index number
Question 5 Multiple Choice (Single Answer)

The function toascii() is declared in the header file _________.

  1. stdio.h
  2. math.h
  3. ctype.h
  4. string.h
Question 6 Multiple Choice (Single Answer)

Which of the following functions is used to input data from keyboard?

  1. cout
  2. cin
  3. cerr
  4. get
Question 7 Multiple Choice (Single Answer)

A stack is a linear data structure in which data is stored and retrieved in a _______.

  1. <>
  2. ##
  3. !=
  4. :=
Question 8 Multiple Choice (Single Answer)

A stack is a linear data structure in which data is stored and retrieved in a _____.

  1. Last Out First In (LOFI)
  2. Last In First Out (LIFO)
  3. First In First Out (FIFO)
  4. Last In Last Out (LILO)
Question 9 Multiple Choice (Single Answer)

Which of the following statements is the terminator in C++?

  1. ;
  2. ,
  3. :
  4. /
Question 10 Multiple Choice (Single Answer)

The keyword 'void' is used to _____.

  1. declare a member function that is defined in a subclass
  2. designate the absence of a type
  3. declare objects that can be modified outside of program control
  4. declare a synonym for an existing type
Question 11 Multiple Choice (Single Answer)

In C++, 'while' is a/an __________ control structure.

  1. sequential
  2. count
  3. repetitive
  4. incremental
Question 12 Multiple Choice (Single Answer)

When a multi-dimensional array is accessed, each array index is ________.

  1. separated by commas
  2. surrounded by brackets and separated by commas
  3. separated by commas and surrounded by brackets
  4. surrounded by brackets
Question 13 Multiple Choice (Single Answer)

Operator Overloading is _____.

  1. Making C+ operators work with objects
  2. Giving C++ operators more than they can handle
  3. Giving new meanings to existing C++ operators
  4. Making new C++ operators
Question 14 Multiple Choice (Single Answer)

On which of the following languages is C++ based?

  1. FORTRAN
  2. PASCAL
  3. C
  4. JAVA
Question 15 Multiple Choice (Single Answer)

Which of the following characters is known as a newline character?

  1. r
  2. d
  3. l
  4. c
Question 16 Multiple Choice (Single Answer)

What will be the output of the under given program?
#include<iosteam.h>
void main()
{
int k;
cout<<”k=”<<k;
}

  1. An error
  2. Unpredictable
  3. 567
  4. 0
Question 17 Multiple Choice (Single Answer)

Who developed C++?

  1. Dennis Ritchie
  2. Bjarne Stroustrup
  3. Blaise Pascal
  4. John Von Neuman
Question 18 Multiple Choice (Single Answer)

Which of the following operators is used for modulus or remainder?

  1. /
  2. //
  3. %
  4. %%
Question 19 Multiple Choice (Single Answer)

A pointer is _____.

  1. the address of a variable
  2. an indication of the variable to be accessed next
  3. a variable for storing addresses
  4. the data type of an address variable
Question 20 Multiple Choice (Single Answer)

What error would the following function give on compilation?
f(int a, int b)
{
int a;
a=20;
return a;
}

  1. Missing parentheses in return statement.
  2. The function should be defined as int f(int a, int b).
  3. Redeclaration of 'a'.
  4. None of the above
Question 21 Multiple Choice (Single Answer)

The 'goto statement' causes control to go to _____.

  1. an operator
  2. a label
  3. a variable
  4. a function
Question 22 Multiple Choice (Single Answer)

What will be the output of the given program?
#include<iostream.h>
void main ( )
{
int a=5;
cout<< ++a;
}

  1. 6
  2. 5
  3. 4
  4. 0
Question 23 Multiple Choice (Single Answer)

The library function exit ( ) causes an exit from _____.

  1. the loop in which it occurs
  2. the block in which it occurs
  3. the function in which it occurs
  4. the program in which it occurs
Question 24 Multiple Choice (Single Answer)

What will be the output of the given program?
#include<iostream.h>
void main ( )
{
int a=1;
for(;;)
{
cout<< a++;
if(a>10)
break;
}
}

  1. The condition in the for loop is must.
  2. The two semicolons should be dropped.
  3. The for loop should be replaced by a while loop.
  4. No error
Question 25 Multiple Choice (Single Answer)

What will be the output of the given program?
#include<iostream.h>
void main ( )
{
cout<< 5+ “Hello world”;
}

  1. Error
  2. Hello
  3. World
  4. None of the above