Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Consider the following strings variable definitions char sl\" love\" char s2[

ID: 3742636 • Letter: 2

Question

2. Consider the following strings variable definitions char sl" love" char s2[] -"to program!"; Char s3[] - "I am, therefore char s4 [80] "; strcpy ( s4, "CSE 5A!"); What gets printed? printf( "%c", s2 [5] ); printf( "%d", strlen ( s1 ) printf( "%d", sizeof( s4 ) ); Fill in the blanks to complete the following tasks The resulting output is "CSE 5A! loves you" in a single printf) statement.*/ printf( "% /*Change the '!' in string s2 to '?'*/ 1m /*Change 't' in string s3 to 'T' without explicitly assigning the value 'T' ;*Cannot have 'T' here! For example, you CANNOT do something like: blahblahblah -'T'

Explanation / Answer

printf("%c", s2[5]); // prints o

s2[5] means 6th character in s2 because the indices start from 0.

printf(" %d", strlen(s1)); // prints 5

Length of the s1 is 5

printf(" %d", sizeof(s4)); // prints 80

Because there s4 can hold 80 characters and each character takes 1 byte of memory

printf("%s%s%s", s4, s1, "s you");

// Output: CSE 5A! loves you

s2[10] = '?';

s3[6] = 84;

printf("%s", s3); // prints I am, Therefore

84 is the ASCII value of the character T

// Hit the thumbs up if you are fine with the answer. Happy Learning!