Question: What is wrong with the following program? #include int sum _ ints ( ) { int * some _ ints = new int [ 5

What is wrong with the following program?
#include
int sum_ints(){
int *some_ints = new int[50];
for (int i =0; i <50; ++i){
some_ints[i]= i;
}// for i
int sum =0;
for (int i =0; i <50; ++i){
sum += some_ints[i];
}// for i
return sum;
}// sum_ints()
int main(){
std::cout << sum_ints();
}// main()
Group of answer choices
sum_ints()indexes out of bounds into some_ints
sum_ints() leaks the memory pointed to by some_ints
some_ints points to uninitialized memory
main() must have a return statement
nothing is wrong with this program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!