For each of the given program segments, determine if there is an error in the co
ID: 3701208 • Letter: F
Question
For each of the given program segments, determine if there is an error in the code, circle the error in the program and write the corrected code in the space provided after each problem. If the code does not contain an error, write "no error." Note: it is possible that a program segment mayotain mutple errors. a)#include b) arraySize 10 c) Assume that int b[ 10 ] = { }; for ( int i-0; i(z10; ?++ ) b[i]-1; o Assume that int a[ 2 ][ 2] 1, 23, {3,4;; al 1, 1-5 e) To indicate that 100 locations should be reserved for integer array p, you write the declaration p[ 100Explanation / Answer
a)#include<iostream>; //error ; semi colon is present
b) arraySize = 10; //data type is required for arraySize
c) int b[10]= {}; // number of assignments of values increases the size of array
for(int i=0;i<10;i++) b[i] = 1;
d) int a[2][2] = {{1,2},{3,4}};
a[1][1] = 5; //indexing is not done properly for 2D array
e) p[100] //no error
*Note: for answer e, i am considering that data type is mentioned for array p, if not then it has error (data type is required for array p)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.