What will be the output of the following C++ code? 1. #include <iostream> 2. using namespace std; 3. int main () 4. { 5. int numbers[5]; 6. int * p; 7. p = numbers; *p = 10; 8. p++; *p = 20; 9. p = &numbers[2]; *p = 30; 10. p = numbers + 3; *p = 40; 11. p = numbers; *(p + 4) = 50; 12. for (int n = 0; n < 5; n++) 13. cout << numbers[n] << ","; 14. return 0; 15. } a) 10,20,30,40,50, b) 1020304050 c) compile error d) runtime error
What will be the output of the following C++ code? 1. #include <iostream> 2. using namespace std; 3. int main () 4. { 5. int numbers[5]; 6. int * p; 7. p = numbers; *p = 10; 8. p++; *p = 20; 9. p = &numbers[2]; *p = 30; 10. p = numbers + 3; *p = 40; 11. p = numbers; *(p + 4) = 50; 12. for (int n = 0; n < 5; n++) 13. cout << numbers[n] << ","; 14. return 0; 15. } a) 10,20,30,40,50, b) 1020304050 c) compile error d) runtime error
Share
a) 10,20,30,40,50,