Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I need some help with fixing my code to fit the requirements for this assignment I would like some assistance with correcting and if

Hello I need some help with fixing my code to fit the requirements for this assignment I would like some assistance with correcting and if you are able to please post the new correct code along side a short explanation, I will post the code I submitted alongside the corrections the module is asking for.

Here is the Question:

image text in transcribed

My code:

#include

#include

#include

int area(int l, int b){

return l*b;

}

int main(int argc, char const *argv[])

{

int l1,l2,b1,b2;

printf("Enter the length and width of the room");

scanf("%d%d",&l1,&b1);

printf(": Enter the length and width of the desk: ");

scanf("%d%d",&l2,&b2);

if(area(l1,b1)>=area(l2,b2)){

printf("The desk will fit in the room. ");

}

else

printf("The desk will not fit in the room. ");

return 0;

}

My code picture:

image text in transcribed

The correction being requested:

image text in transcribed

image text in transcribed

This problem will be discussed in Lab6 and the TA will give you hints to solve most of it. However, the TA may not write the complete code. If you have labs on Monday, try to understand the process from the TA so that you can complete it. You will also gain more backgounrd of writing functions from the main lecture section and that will help you to complete the code in combination of the lab session. Problem: You need to write a code to decide whether or not a desk will fit a room (with its sides parallel to the room) given the dimensions of both. The function sizeCheck() takes in 4 parameters, two for length and width of the room and two for the length and width of the desk. (All lengths should be considered as integers and the parameter list should match with the sequence mentioned above). Based on the parameter, it returns 1 if the desk fits or returns O if the desk does not fit. In the main function, you should take all the inputs and call the sizeCheck() function. Based on the returned value by the function, print the appropriate message in the main function. If you think a bit, only knowing the area of the room and desk is not enough to make this decision due to thelr shapes. For example, see the following sample Input/Output 3, where the area of the room is bigger than the area of the desk, however, that desk will not fit in the room. Sample Input/Output 1: Enter the length and width of the room: 10 10 Enter the length and width of the desk: 10 10 The desk will fit in the room Sample Input/Output 2: Enter the length and width of the room: 1214 Enter the length and width of the desk: 14 12 The desk will fit in the room. Sample Input/Output 3: Enter the length and width of the room: 2117 Enter the length and width of the desk: 10 22 The desk will not fit in the room. Rubric: 2 points You must have to write the function and use it to get the full credit. 1 #include 2 3 #include 4 5 #include 6 7-int area(int 1, int b) { 8 9 return l*b; LO 11 } 12 | 13 int main(int argc, char const *argv[]) 14 15 - { 16 17 int li, 12,b1,b2; 18 19 printf("Enter the length and width of the room"); 21 scanf("%d%d",&li,&bl); 22 23 printf(": Enter the length and width of the desk: "); 24 25 scanf("%d%d",&12,&b2); 26 27-if(area(li,b1)>=area(12,62)){ 28 29 printf("The desk will fit in the room."); 30 31 } 32 33 else 34 35 printf("The desk will not fit in the room. "); 36 37 return 0; 38 39} Debugging Information for Test Case 2 O X Your instructor has chosen to give you the following information to help you debug your code and improve your submission. COMPILER STACK TRACE None PROGRAM EXECUTION STACK TRACE None INPUT OF THE TEST CASE 1 10 2 10 39 4 8 YOUR CODE'S OUTPUT 1 Enter the length and width of the room: Enter the length and width of the desk: The desk will not fit in the rod THE CORRECT OUTPUT OF THE TEST CASE 1 Enter the length and width of the room: Enter the length and width of the desk: The desk will fit in the room. UNIX DIFF OF CORRECT OUTPUT AND YOUR OUTPUT 1c1 k Enter the length and width of the room: Enter the length and width of the desk: The desk will not fit in the room No newline at end of file > Enter the length and width of the room: Enter the length and width of the desk: The desk will fit in the room. No newline at end of file PRETTY DIFF This diff is colored to make it clear what parts of the output are wrong. Green indicates things in the correct output that you are missing, red indicates things in your output that shouldn't be there. The + character refers to newlines, so the green character refers a newline you are missing in your output and the red refers to a newline you need to remove from your output Enter the length and width of the room: Enter the length and width of the desk: The desk will not fit in the room. Have you written the sizeCheck() function properly and called it properly? COMPILER STACK TRACE mimir.c: In function 'test_mimir': C_unit_test:1:16: warning: implicit declaration of function 'sizeCheck' [-Wimplicit-function-declaration] int result sizeCheck(15, 20, 21, 9); /tmp/cCYK3k2t.o: In function 'test_mimir': mimir.c:(.text+0x125): undefined reference to sizeCheck collect2: error: ld returned 1 exit status? WHAT DO THESE ERRORS MEAN? This typically means that you have variables not defined and the most common cause are typos and spelling mistakes.Check for spelling differences AMANAN PROGRAM EXECUTION STACK TRACE None YOUR CODE'S OUTPUT 1 **FAILED TO COMPILE** ANNNNNN mimir.c: In function 'test_mimir': C_unit_test:1:16: warning: implicit declaration of function 'sizeCheck' [-Wimplicit-function-declaration] int result sizeCheck (15, 20, 21, 9); /tmp/cCYK3k2t.o: In function 'test_mimir': mimir.c:(.text+0x125): undefined reference to sizeCheck collect2: error: ld returned 1 exit status? WHAT DO THESE ERRORS MEAN? This typically means that you have variables not defined and the most common cause are typos and spelling mistakes.Check for spelling differences. SOLUTION CODE OUTPUT 1 Running test suite with seed exiff6ab3c... 2 mimir/test 3 We are calling your sizeCheck function with 15, 20, 21, 9 as the actual parameters. Your sizeCheck function is returning a The correct result should be a 7 ---- 4 5 6 8

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

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

(8) What am I doing to stretch the high achievers?

Answered: 1 week ago