PLEASE ANSWER ALL
2.
3.
4.
5.
6.
Consider the following code snippet: for (int i = 0; i <10; ) { cout << "hello"; i=i+9; } What does this code snippet display? hello hello hello hello hello hello "hello"
Consider the following code snippet: int x = -1; if(true) 0 return; x = 0; cout << x << endl; What will be displayed? X else nothing
Which of the following statement is false? switch is a selection statement. while is an iteration statement. return is a selection statement. break is a jump statement.
Which of the following two statements are infinite loops? for(int i = 0; i > 10; i++) { } while(true) {} do[] while(false); for(int i = 0; i<10; i--) { }
Consider the code segment below. What will be the value of sum? int sum = 0, z; // z is assigned a value by some statement before the // while loop and that the while loop is entered. while(z >= 0) { } zero sum +=z; infinity either zero or infinity some finite value
Consider the code snippet below: char stamp; int value; switch (stamp) { case 'A': value = 100; break; case '@': value = 50; break; case 'h': value = 120; break; default: value = 0; } For what value of stamp such that value is 120?
PLEASE ANSWER ALL 2. 3. 4. 5. 6.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am