Question: D Instructions for Q5 - Q7: A programmer writes a small C program, and organizes her code into three files, as shown below: ff




D Instructions for Q5 - Q7: A programmer writes a small C program, and organizes her code into three files, as shown below: ff qmain.c #include #include cinttypes.h> uint32_t global = 42; int main() { uint32_t A global; helper (A); return 0; // 1 2 // 11 3 // 3 1/4 // 5 // 6 7/7 // 8 // 10 // Utils.c #include #include void helper(uint32_t x) { II 1 11 2 11 6 11 S 1/ 10 // should return 42*42 - 18 uint32_tr friend(x); // 11 // 12 11 13 printf("r: "PRIU32 ", r): global = 10; uint32_t A global; helper (A); return 0; // Utils.h #ifndef UTILS H #define UTILS H #include Tendif 11 A 11 5 // 6 11 7 11 8 11 9 // 18 // 1 11 2 global-19; } 11 7 // 10 // should return 42*42 18 uint32_t r friend(x); // 11 // 12 // 13 printf("r: X*PRIU32" ", r); static uint32_t friend(uint32_t z) { // 15 1716 return (22 global ); As shown, the code does not compile. The error messages shown in Q5 - Q7 are generated. For each question, write the code you would add in order to eliminate the error(s) described in that question. Indicate where the code would be added by referring to file names and line numbers shown in the given code. For example, you might (incorrectly) say to add: //q3main.c line 6 Do not make any alterations to the C statements that are given; you may only insert additional statements. Question 5 4 pts Question 5 centos> gcc -o q5-std-c11 -Wall -W q5main.c Utils.c Utils.c: In function "helper': Utils.c:8:4: error: 'global' undeclared (first use in this function) global 10; Edit View Insert Format Tools Table 12pt Paragraph BIUATV OND
Step by Step Solution
3.61 Rating (148 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
