Question: Please help me with those Computer science homework problem. Thanks!! Question is below, thank you a lot!! Code: #include #include main() { int i; char

Please help me with those Computer science homework problem. Thanks!! Question is below, thank you a lot!!

Code:

Please help me with those Computer science homework problem. Thanks!! Question is

#include

#include

main() {

int i;

char s[5], s1[ ] = "hello", s2[5] = "world"; // s2[5] = "world" incorrect;

for (i = 0; i

printf("%c", s1[ i ]);

printf(" ");

printf("s1 = %s, size = %d ", s1, sizeof s1);

for (i = 0; i

printf("%c", s2[ i ]);

printf(" ");

printf("s2 = %s, size = %d ", s2, sizeof s2); // no end of string

strcpy(s, s1); // unsafe: copy size 6 to 5

printf("s = %s, size = %d ", s, sizeof s);

}

1 .At line 5: how many bytes will be allocated to array s1[ ] by the compiler?

(A) 1. (B) 5 (C) 6 (D) 40

2 . At line 5: char s[5], s1[ ] = "hello", s2[5] = "world"; What would happen if s[5] is replaced by s[ ]?

(A) The problem is fixed and no error at this line.

(B) A contextual error will occur at compilation time.

(C) The program will crash at run time.

(D) No error will be reported, but a semantic error will occur.

3 .At line 5: What is the difference if s1[ ] = "hello" is replaced by s1[ ] = {'h', 'e', 'l', 'l', 'o'} ?

(A) There is no difference.

(B) A contextual error will occur at compilation time.

(C) A semantic error will occur at compilation time.

(D) No error will be reported, but a semantic error can occur.

2 3 I o o o voor A #include #include main() { int i; char s[5], s1[ ] = "hello", s2[5] = "world"; // s2[5] = "world" incorrect; for (i = 0; i

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 Databases Questions!