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

PLEASE read the directions carefully . • This program is written in C. • This pr

ID: 3829618 • Letter: P

Question

PLEASE read the directions carefully.

• This program is written in C.

• This program prints “there hi ”

• You must modify this program so that it prints “hi there ”

IMPORTANT: You may only add code at the “// your code here” section. You may add as many lines as necessary, but NO EXISTING CODE CAN BE MODIFIED (this also means no new functions can be added).   

IMPORTANT: All printing must be done through the existing printf calls; you may not add your own calls to any output functions (printf, putchar, etc).

• HINT: This assignment can be completed in one line.

#include <stdio.h>
void a();
void b();
void c();
  
int main() {
a();
printf(" ");
return 0;
}

void a() {
b();
printf("hi ");
}

void b() {
c();
printf("there ");
}

void c() {
int x;
// your code here
}

Explanation / Answer

#include <stdio.h>
void a();
void b();
void c();
  
int main() {
a();
printf(" ");
return 0;
}

void a() {
b();
printf("hi ");
}

void b() {
c();
printf("there ");
}

void c() {
int x;
// your code here
static int first = 1;

if (first) {
first = 0;
char buf0[BUFSIZ];
char buf1[BUFSIZ];
setvbuf(stdout, buf0, _IOFBF, BUFSIZ);
b();
memcpy(buf1, buf0 + 6, 3);
memcpy(buf1 + 3, buf0, 6);
memcpy(buf0, buf1, 9);
buf0[8] = ' ';
fflush(stdout);
exit(0);
}  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote