1 Crore+ students have signed up on EduRev. Have you? Download the App |
What is the time complexity of accessing an element in a 2D array by its index?
What will be the output of the following code?
#include <iostream>
int main() {
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
std::cout << arr[1][2];
return 0;
}
What will be the output of the following code?
#include <iostream>
int main() {
int arr[2][2] = {{1, 2}, {3, 4}};
std::cout << arr[1][1] + arr[0][0];
return 0;
}
What will be the output of the following code?
#include <iostream>
int main() {
int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
std::cout << arr[1][2] - arr[0][1];
return 0;
}
What will be the output of the following code?
#include <iostream>
int main() {
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
std::cout << arr[2][1] * arr[0][2];
return 0;
}
What will be the output of the following code?
#include <iostream>
int main() {
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
std::cout << arr[2][0] / arr[1][1];
return 0;
}
Given the following 2D array, what will be the output of the code?
#include <iostream>
int main() {
int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
std::cout << *(arr[1] + 2);
return 0;
}
Given the following 2D array, what will be the output of the code?
#include <iostream>
int main() {
int arr[3][2] = {{1, 2}, {3, 4}, {5, 6}};
std::cout << *(*(arr + 2) + 1);
return 0;
}
Given the following 2D array, what will be the output of the code?
#include <iostream>
int main() {
int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
std::cout << arr[1] - arr[0];
return 0;
}
Given the following 2D array, what will be the output of the code?
#include <iostream>
int main() {
int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
std::cout << sizeof(arr) / sizeof(arr[0]);
return 0;
}
Given the following 2D array, what will be the output of the code?
#include <iostream>
int main() {
int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
std::cout << sizeof(arr[0]) / sizeof(int);
return 0;
}