Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language is C Where is the storage for the hello string literal allocated in memory when this program is run? #include int main(void) { char

Language is C

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Where is the storage for the "hello" string literal allocated in memory when this program is run? #include int main(void) { char * p = "hello"; printf("%s ", p); return 0; O No memory is allocated to "hello". Somewhere else. O On the stack. Incorrect. What does the following code print? #include int main(void) { char c = '0';. if (c) printf("yes "); else printf("no "); return 0; It prints "no." It does not compile. O The standard does not define what the program should print. Incorrect. None of the above. It prints "yes." It crashes. What does the following code print (on a 32-bit machine)? #include void printSize (char * p) { printf("%zu ", sizeof(p)); } int main(void) { char * p = NULL; printSize (p); return 0; It crashes. Incorrect. 4 ( 1 It does not compile. What's the value of sizeof (char)? o It depends on the compiler and operating system, but it's at least 8. It's either 4 on a 32-bit machine or 8 a 64-bit machine. 0 1 O 8 Incorrect What happens when you compile and run this program? (To print value you can use echo $? in the command-line window right af the program.) #include int main(void) { char c = NULL; return c != '\0'; It produces a compilation error.. You selected this a It compiles just fine, even with -Wall - Wextra What happens when you compile and run this program? (To print the return value you can use echo $? in the command-line window right after running the program.) #include int main(void) { char c = NULL; return c != '\0'; } It compiles just fine, even with Wall - Wextra. It produces a compilation warning, but then it returns 0. It crashes. It produces a compilation error. Incorrect It returns -1. What does the following program print when executed? #include int main(void) { char c[] = "35"; C[0]++; printf("%s ", c); return 0; 4G OG It prints nothing because it crashes when it tries to modify read-only memory. What does the following program print when run? #include int main(void) { char str[] = "complement"; char * p = str; p[sizeof(str)-6] = 'i'; printf("That's quite a %s! ", str); return 0; O That's quite a compiement! That's quite a complement! O The program does not compile. O That's quite a compliment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions