Question

c++ What is wrong with the following code segment? Fix the error and explain why its...

c++ What is wrong with the following code segment? Fix the error and explain why its wrong.

int* m[3];

for(int i = 0; i < 3; i++)

m[i] = new int[4];

delete [] m;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

An swer

int* m[3];
for(int i = 0; i < 3; i++)
   m[i] = new int[4];
for(int i = 0; i < 3; i++)
   delete m[i];

Note: Please comment below if you have any doubts

Please upvote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
c++ What is wrong with the following code segment? Fix the error and explain why its...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is wrong with the following program? Explain how you will fix it in the code....

    What is wrong with the following program? Explain how you will fix it in the code. #include int main() { int i; int *ptr = &i; scanf("%d", &ptr); printf("The value of i is: %d\n", *ptr); return 0; }

  • Part II: Programming Errors Fix the Errors in C++ Segments of Code and C++ Programs (10...

    Part II: Programming Errors Fix the Errors in C++ Segments of Code and C++ Programs (10 Marks) 1. Find the error(s) in the following program segment and correct them. int b[10] = [0]; for (int i=0; i <= 10, i++) b[i] = 2*i+3;

  • Java Programming Language: Find the compiling error in the following code segment. Explain what the problem...

    Java Programming Language: Find the compiling error in the following code segment. Explain what the problem is and how to fix it. public class Mark { private float value;        public float Mark(float startValue) {        value = startValue; } }

  • What is wrong with this Code? Fix the code errors to run correctly without error. There...

    What is wrong with this Code? Fix the code errors to run correctly without error. There are two parts for one code (one question) the two parts branch off, one part has 2 sheets of code, the other has 3 sheets of code, all are small code segments for one question. Pt.1 - 2 sheets of code: public class Computer { private String make; private String type; private String modelNumber; private double cpuSpeed_GHz; private int ramSize_GB; private int hardDriveSize_GB; private...

  • Given the following code segment, int x = 20; int y = 7; what is the...

    Given the following code segment, int x = 20; int y = 7; what is the data type of the value of the expression (x % y) ? (3 points) Question 1 options: 1) int 2) double 3) numeric 4) Error: possible loss of precision 5) Unable to be determined Question 2 (3 points) Given the following code segment, double x = 42.3; double y = 11.7; what is the data type of the value of the expression (x %...

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

    20) What is the output of the following segment of C code: int avg(int n, int* a); int main () {             int array[4]={1,0,6,9};             printf("%d", avg(4, array)+ 1);             system("pause");             return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...

  • 1. What is the output of the following code segment? int array[] = { 8, 6,...

    1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...

  • help with these c++ questions I believe I had submitted the wrong answer and want to...

    help with these c++ questions I believe I had submitted the wrong answer and want to know if I had got it right [8 points) Consider the following code: 16 Foo :: Foo() { delete () arr; 2 17 } 4 class Food public: Foo(); *Foo(); private: int #arr: }; 18 19 20 21 5 6 void init (Fool param) { Foo obj: param = obj: 22 23 8 } 24 0 Foo :: Foo() { arr = new int...

  • Consider the following C++ code segment: for (int i = 0; i <n; ++i) { for...

    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

  • for this code fix the smtax error this is a python code for some reason my...

    for this code fix the smtax error this is a python code for some reason my code isnt liking my returns and it bring up other symtax error so fix the following code answer should pop out the following when runned 1/ 2 + 1/ 3 + 1/ 12 = 11/12 z=' ' def math(x,y):     global z     if y==0 or x==0:         return     if y%x ==0:         z=("1/"+str(int(y/x))         return      if x%y ==0         z+=(int(x/y))    ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT