0

C/C++

Description: C/C++
Number of Questions: 21
Created by:
Tags: C Programming C++ Programming IT Companies Computer Basics
Attempted 0/21 Correct 0 Score 0

Which data type is in C++ but not in C?

  1. Int

  2. Char

  3. Bool

  4. Double


Correct Option: C
Explanation:

This is a new data type introduced in C99, standard of C++.

Which of the following represents correct declaration of sprintf function in C?

  1. Int sprintf ( char * str, const char * format)

  2. Void sprintf ( char * str, const char * format, ...)

  3. Int sprintf ( int, const char * format, ... )

  4. Int sprintf ( char * str, const char * format, ... )


Correct Option: D
Explanation:

This is the correct answer as it returns integer which represents the number of characters successfully written on string (first argument). Also the three dots at the end represents that it can have variable number of arguments which is required.

Which of these is not a standard C/C++ function?

  1. Atoi

  2. Itoa

  3. sprintf

  4. printf


Correct Option: B
Explanation:

This was not included when C++ was standardized in 1999.

Which type of access structure member in C++ is by default?

  1. Private

  2. Public

  3. Default

  4. Protected


Correct Option: B
Explanation:

C++ structures and classes are same. The only difference is that C++ structures have public access by default while Class members have private access by default.

Why does not the following statement work?

char temp[] = Hurry; strcat(temp,'!');

  1. There is no problem in the above statement.

  2. Because the second argument is a character.

  3. Because the first argument is of type char*.

  4. The strcat declaration also takes length of string as an argument.


Correct Option: B
Explanation:

 The string function strcat( ) concatenates strings and not a character.

How can we create an abstract class in C++?

  1. By defining virtual functions in class

  2. By defining pure virtual functions in class

  3. By defining virtual destructor

  4. By defining virtual constructor


Correct Option: B
Explanation:

 Abstract classes act as expressions of general concepts from which more specific classes can be derived. You cannot create an object of an abstract class type. However, you can use pointers and references for abstract class types.

A class that contains at least one pure virtual function is considered as an abstract class. Classes derived from the abstract class must implement the pure virtual function. 

What is the maximum value that an 'unsigned short int' can hold?

  1. 32767

    • 32767
  2. 65535

  3. 0


Correct Option: C
Explanation:

An unsigned short int is a 16 bit positive number and its range is from 0 to 65535.

Which function is used to get the drive number of disk?

  1. A setdisk

  2. A getdisk

  3. A namedisk

  4. A returndisk


Correct Option: B
Explanation:

The function getdisk( ) returns the drive number of current drive. The drive number 0 indicates 'A' as the current drive, 1 as 'B' and so on.

The macro EXIT_SUCCESS is defined in ___________header in standard C++.

  1. The,cstdio

  2. The.cstring

  3. The,cstdlib

  4. The,iostream


Correct Option: C
Explanation:

This macro expands to a system-dependent integral expression that, when used as the argument for function exit should signify that the application was successful. It is defined in header cstdlib.

Which parameter is added to every non-static member function of class?

  1. The virtual

  2. The public

  3. The final

  4. This pointer


Correct Option: D
Explanation:

 This pointer is added to every non-static member of class.

C is often called as

  1. high level language

  2. assembly level language

  3. machine level language

  4. middle level language


Correct Option: D
Explanation:

C is called a middle level language because it combines the best elements of high level language with the control and flexibility of assembly level languages.

Which of the following data types is not defined by C?

  1. Char

  2. Int

  3. Bool

  4. Double


Correct Option: C
Explanation:

The char, int, float, double and void are five data types defined by C. In C++ , add two more- bool and wchar_t. Hence, bool is the correct option.

Which of the following is not calling the copy constructor of class given below?

Class Test { public: Test(int i ); };

  1. Test Obj2(Obj1);

  2. Test Obj2 = Obj1;

  3. Test Obj1,Obj2;Obj2 = Obj1;

  4. None of these


Correct Option: C
Explanation:

Here default assignment operator is called as we have not overloaded assignment operator. So, this is the correct option as copy constructor will not be called here.

Which of the following functions is not defined in string.h?

  1. strcmp

  2. strlen

  3. strcat

  4. pow


Correct Option: D
Explanation:

The pow is used to calculate the result of base raised to power exponent and is defined in math.h.

Which of the following does not fall under the category of systems program?

  1. Operating system

  2. Device drivers

  3. Microsoft word

  4. Compilers


Correct Option: C
Explanation:

 Microsoft word is an application software developed by Microsoft. So, it does not fall under the category of systems program.

In which of the following headers files is FOPEN_MAX macro defined?

  1. math.h

  2. stdlib.h

  3. stdio.h

  4. string.h


Correct Option: C
Explanation:

FOPEN_MAX means the number of files that can be opened by a program at any point of time and is defined in stdio.h. Hence, it is the correct answer.

If we declare integer array with dimensions 10, 5; how many bytes will be allocated for it in memory for a 32-bit machine?

  1. 100 bytes

  2. 200 bytes

  3. 300 bytes

  4. 400 bytes


Correct Option: B
Explanation:

In a 32-bit machine, integer will occupy 4 bytes. Therefore, answer should be 10*5*4 = 200 bytes. Hence, it is the correct answer.

Which of the following is not a storage class specifier?

  1. Extern

  2. Auto

  3. Register

  4. Volatile


Correct Option: D
Explanation:

Volatile is not a storage class specifier. However, it is a qualifier which tells the compiler that  variables may be changed in ways not explicitly specified by the program.

Which of the following functions is defined in ctype.h?

  1. Exit

  2. strcmp

  3. Tolower

  4. Gets


Correct Option: C
Explanation:

Tolower is defined in ctype.h. Hence, it is the correct answer.

Who invented C++?

  1. Dennis Ritchie

  2. Ken Thompson

  3. Bill Gates

  4. Bjarne Stroustrup


Correct Option: D
Explanation:

C++ was developed by Bjarne Stroustrup in 1979. Hence, this is the correct answer.

Which of the following is a structured language?

  1. Dot Net

  2. C++

  3. Java

  4. C


Correct Option: D
Explanation:

All modern languages, like, C++, Java, Dot Net etc. are object oriented languages and C is a structural language.

- Hide questions