C++ Test

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View C++ Test as PDF for free.

More details

  • Words: 591
  • Pages: 4
Which of the following represent valid variable definitions? int n = -100; unsigned int i = -100; signed int = 2.9; long m = 2, p = 4; int 2k; double x = 2 * m; float y = y * 2; unsigned double z = 0.0; double d = 0.67F; float f = 0.52L; signed char = -1786; char c = '$' + 2; sign char h = '\111'; char *name = "Peter Pan"; unsigned char *num = "276811";

Which of the following represent valid identifiers? identifier seven_11 _unique_ gross-income gross$income 2by2 default average_weight_of_a_large_pizza variable object.oriented

Which of the following are invalid variable names and why? BASICSALARY _basic #MEAN group. population in 2006 overtime FLOAT hELLO team’svictory Plot # 3

basic-hra 422 mindovermatter queue. 2015_DDay

int a, b ; a = -3 - - 3 ; b = -3 - - ( - 3 ) ; cout<< a<< b ; Ans a=0 and b= -6 A character variable can at a time store (1) 1 character

(2) 8 characters (3) 254 characters (4) None of the above A C++ variable cannot start with (1) An alphabet (2) A number (3) A special symbol other than underscore (4) Both (2) & (3) above (q) (1) (2) (3) (4)

The expression, a = 30 * 1000 + 2768 ; evaluates to 32768 -32768 113040 0

What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run? A. 10 B. 9 C. 0 D. 1 4. How many times is a do while loop guaranteed to loop? A. 0 B. Infinitely C. 1 D. Variable void main() { int i; for(i=1;i<4,i++) switch(i) case 1: printf("%d",i);break; { case 2:printf("%d",i);break; case 3:printf("%d",i);break; } switch(i) case 4:printf("%d",i); } Ans: 1,2,3,4 Single line comments explaining code would be preceded like in the following example

/**

//

*//

/*

What punctuation must each command line have at the end of the line?

: , ! ; The C++ language is case-sensitive. Not case-sensitive. It depends None of these Select the correct definition for a string variable . string mystr; string mystr[20]; string[20] mystr; char mystr[20]; Cout can print multiple values or variables in a single command using the following syntax: cout << "Hi" + bob + "\n"; cout << "Hi" << bob << "\n"; cout << "Hi", bob, "\n"; cout << ("Hi" & bob & "\n"); Write a for loop that counts from 0 to 5 for (c = 0; c <= 5; c++) for (int c = 0; c <= 6; c++) for (c = 0; c < 5; c++) for (c = 0; c < 5; c++); Indicate which data type is not part of standard C++. bool int real double What is the output of the following code? for (int i=0; i<10; i++); { cout << i%2 << " "; } 0123456789 0 2 4 6 8 10 12 14 16 18 1010101010 0 What is the output of the following code? for (int i=0; i<10; i++); { cout << i%2 << " "; }

0123456789 0 2 4 6 8 10 12 14 16 18 1010101010 0101010101 Which of the following is the boolean operator for logical-and? A. & B. && C. || D. |&s . Evaluate !(1 && !(0 || 1)). A. True B. False C. Unevaluatable 4. What is the result of the following code? x=0; switch(x) { case 1: printf( "One" ); case 0: printf( "Zero" ); case 2: printf( "Hello World" ); }

A. One B. Zero C. Hello World D. ZeroHello World

Related Documents

C++ Test
November 2019 21
C++ Test
May 2020 6
Citi C Stress Test
December 2019 20
Inplacerings Test C
November 2019 31
C Multitouch Design-test
October 2019 14
C Programmers Test
November 2019 21