C and C++ Programming Fundamentals

Test your knowledge of C and C++ programming concepts including operators, arrays, functions, classes, constructors, variables, and compilation basics

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What will be output if you will execute following c code?

  1. 6
  2. 7
  3. 8
  4. 9
  5. CompilationError
Question 2 Multiple Choice (Single Answer)

What will be output if you will Execute following c code?

  1. 5,4
  2. -4,4
  3. -5,4
  4. -4,5
  5. Compilation Error
Question 3 True/False

We need to have a structure day of type date which has the following values. date day = {17,2,2011}; Will the following Structured Declaration Correct?

  1. True
  2. False
Question 4 Multiple Choice (Single Answer)

Which of the following statements are correct?

  1. Relational and equality operators evaluate their operands to produce a true or false result.
  2. The equality operators have the same level of precedence And associate right to left.
  3. Relational operators all have the same level of precedence And associate right to left.
  4. The precedence of relational operators is at a lower level Than the precedence of the equality operators.
Question 5 Multiple Choice (Single Answer)

Which of the following will occur when trying to validate the below code Segment?

  1. Syntax Error
  2. Linker Error
  3. Runtme Error
  4. No Error, It will be run successfully
Question 6 Multiple Choice (Single Answer)

setprecision requires the header file

  1. stdlib.h
  2. iomanip.h
  3. console.h
  4. conio.h
Question 7 Multiple Choice (Single Answer)

If char catname[15]; , which of the following is valid?

  1. catname[15] = "Millie";
  2. catname = "Millie";
  3. catname[ ] = "Millie";
  4. None are Valid
Question 8 Multiple Choice (Single Answer)

Variables with names that describe the data Stored at that particular memory location are called as

  1. identifiers
  2. constant variables
  3. floating point variables
  4. mnemonic variables
Question 9 Multiple Choice (Single Answer)

The other name for external variables in C++ is

  1. static variables
  2. register variables
  3. global variables
  4. None of the Above
Question 10 Multiple Choice (Single Answer)

Class that reads and writes to an array in memory is

  1. ostream
  2. ifstream
  3. strstream
  4. None of the Above
Question 11 True/False

Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?

  1. True
  2. False
Question 12 Multiple Choice (Single Answer)

What is the value of x when the below code segment is executed?

  1. 10
  2. 20
  3. Compilation Error
  4. RuntimeError
Question 13 Multiple Choice (Single Answer)

What happens when the following code segment is Validated?

  1. Complies Successfully
  2. Error Due to Duplicate Variables.
  3. RunTime Error
  4. Executes Successfully
Question 14 Multiple Choice (Single Answer)

Which of the following statements are correct about Function prototypes?

  1. It resembles the header Of the function definition
  2. It tells the compiler the Names of the parameters
  3. It must be declared before its corresponding functions can be utilized
  4. All the above are incorrect
Question 15 Multiple Choice (Single Answer)

What the following program is executed?

  1. CompilationFails
  2. Will Throw RunTime Error But Code will get Compiled
  3. Throws Linker Error
  4. All the above statements are invalid
Question 16 Multiple Choice (Single Answer)

Using pointers to call a function is called as

  1. call by value
  2. call by reference
  3. call by address
  4. All the Above
Question 17 Multiple Choice (Single Answer)

The member functions of a class can be defined outside the Class using

  1. Extraction Operator
  2. Insertion Operator
  3. Scope resolution operator
  4. None of the Above
Question 18 Multiple Choice (Single Answer)

Which of the following will occur when trying to validate the below code Segment? #define <iostream.h> #define <GetSquareOfx.hpp> // GetSquareOfx function-prototype has the following defn // int GetSquareOfx(int) ; Int main() { int x =5 ; Cout << GetSquareOfx() ; return x ; }

  1. Syntax Error
  2. Linker Error
  3. Runtme Error
  4. No Error, It will be run successfully
Question 19 Multiple Choice (Single Answer)

What will be output if you will execute following c code? #include<stdio.h> #include<conio.h> void main() {     int a[]={0,1,2,3,4,5,6,7,8,9,10};     int i=0,num;     num=a[++i+a[++i]]+a[++i];     printf("%d",num); }

  1. 6
  2. 7
  3. 8
  4. 9
  5. CompilationError
Question 20 Multiple Choice (Single Answer)

What will be output if you will Execute following c code? #include<stdio.h> int main() {     int num,a=5;     num=-a--;     printf("%d  %d",num,a); }

  1. 5,4
  2. -4,4
  3. -5,4
  4. -4,5
  5. Compilation Error