CSE114 labwork1 Solved

40.00 $

Description

5/5 - (1 vote)

LABWORK RULES

● Labwork ends  18.50. ● Name of your file should be in the format: labwork1_name_surname.c

○ Name: is your own name ○ Surname: is your own surname ○ Example: labwork1_name_surname.c ○ If you do not know how to create a c file, please look at “how to run your code”

file

● Your file should be on the desktop ● At 18.50, we collect your works from your desktop. Do not turn off your computer until

you are told to do so…

● You will not have an internet connection until we collect your works. When the access is

permitted, submit your work on coadsys.

● The work we collect and you submitted on coadsys should be exactly the same. ● Read your labwork documents carefully and listen to the explanation of your assistant. ● There can be restrictions on your labwork, obey them if you want to get a full grade. ● If you did not understand the labwork or there is an unclear point, do not make

assumptions and ask your assistant immediately.

● There will be some example input and output for each labwork. Do not write a program that only runs for the given example input. Be sure you understand the question well.

FORBIDDEN

● Talking with your friends ● Looking at your friend’s monitor ● Using any mobile phone or smart devices ● Books, notebooks, papers or notes ● Usb or any kind of device that is used to share information ● Internet

LABWORK 1

Write 3 functions and a main function.

Function 1: (25 pts)

● Function name: squared_diff1 ● Function parameter: 2 integer parameters; x and y ● Return type: integer

● Function calculates and returns

2

2 , if the result is negative, then multiply it with -1. −

Function 2: (25 pts)

● Function name: squared_diff2 ● Function parameter: 2 integer parameters; x and y ● Return type: integer ● Function calculates and returns

( − ) * ( + )

, if the result is negative, then multiply

it with -1.

The main function :

1. Ask x and y values from the user (5 pts) 2. Call squared_diff1 function and calculate its result. (5 pts) 3.

If the result from step 2 is smaller than 20, ask another y value from the user. Otherwise, continue with step 6. (10 pts)

4. Call squared_diff1 function again and calculate its result with the new y value. (5 pts) If the result from step4 is also smaller than 20, then set the y value to x+5. Otherwise, 5. continue with step 6. (10 pts)

6. Call squared_diff2 function and calculate its result (5 pts) 7. Print “SAME” if both of the values returned from the functions match, print “DIFFERENT”

otherwise (10 pts)

8. Do the printf and scanf operations only in the main function.

 

  • Labwork1-peugst.zip