Given Code:
int numbers[]={99,87,66,55,101};
cout<<numbers[i]<<" ";
Output of given code:
error: ‘i’ was not declared in this scope
cout<<numbers[i]<<" ";
If i is declared then
Code is like this
int i;
int numbers[]={99,87,66,55,101};
cout<<numbers[i]<<" ";
The default value of int
is 0 so i=0
Then Output will be numbers[0] that is 99
What is the output of the following code: int numbers [] {99,87,66,55,101}; cout << numbers[i] «...
ed What is the output after execution of the code block {for (int i=1;i<=4; i++) {if (i==3) continue; cout<<"-"<<i; i++}} 1.00 on Select one: a.-1-3 b.-1-2 C.-1-4 O d.-2-3
What is the output of the following code fragment? int i = 1; while( i <= 5 ) if(i == 2 || i == 4) System.out.println(i + ":" + " is an even index) System.out.println("i: " + i); i++;
What is the output of the following code? for(int i =0; i<3; i++) { int x = 0; x = x+i; Sy System.out.println(x);
What is the output of the following C++ code? int count = 1; int num = 25; while (count < 25) { num--; count++; } cout << count « " " « num << endl i 25 1 0 24 1 0 25 0 0 24 0 In this while loop statement, while (counter < 10), where counter is an int variable. Which statement below is an equivalent way to write this while statement? while (10 < counter) while (9...
What is the output? (3 pts) int num = 5; int* ptr = # cout << ptr << endl; cout << &ptr << endl; cout << *ptr << endl;
Consider the following C++ code segment: for (int i = 0; i <n; ++i) { for (int j = 0; j <m; ++j) if (i != j) cout << "0"; else cout << "1"; } } Which of the options below gives the correct output if the value of nis 2and the value of mis 3? 1. 100010 2. 011101 3. 100100 4. 010001
51. What is the output of the following code snippet? int number = 0; int ptr_num -&number ptr_num 60; number-80 cout < "ptr num << endl b, 60 c. 80 d. the address of number Answer 52. What is the output of the following code snippet? double num-0.0; double* ptr = # num = 15.0; ptr ptr 15.0 cout << num <<"ptr <<endl; a. 15 15 b. 15 30 С. 30 15 d. 30 30 Answer: 53. What is the...
What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday";
Consider the following statements. If the input is 95, the output of the following code will be: #include <iostream> #include <string> using namespace std; int main ) { float score; string grade; cin >> score; grade - "Unknown"; if (score >= 90) grade - "A"; if (score > 80) grade - "B"; if (score > 70) grade - "C"; else grade - "F"; cout << grade; }
or (int i - 3; i<ll; i-i+2) Solution: cout< iend; i-i2 B) What will the following program fragment output? (2 points) int mainc int j 7, d 2; double sum 0; 5 Solution: sumd; --ji 9 10 cout<esum; 12 13