Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need the whole cide in c language the project 1 results are attached You must write a C program that generates random numbers in

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

I need the whole cide in c language

the project 1 results are attached

image text in transcribed

You must write a C program that generates random numbers in the range of [100.0,100.0] and, depending on the value of the number, creates a new node at the beginning of one of the four linked lists: positive numbers with a non-zero whole part, positive fractions, negative fractions, and negative numbers with the non-zero whole part. The program stops when the total amount of randomly generated positive numbers reaches the value specified by the user. The nodes of the linked lists must keep: the generated number, the structure with a sign, an exponent, and a mantissa of IEEE 754 representation of the number, the value restored from the IEEE 754 representation, and a pointer to the next node. If the restored value is not equal to the value of the generated number, the node should not be added, and an error message should be printed to stderr. Finally, each linked list must be saved in a separate file, but all four files must have the same extension specified by the user. Special requirements: - The user preferences must be inputted as command-line arguments. - You should use the results of Project 1 as a library function that returns the structure with the sign, exponent, and mantissa. - The user preferences must be inputted as command-line arguments. - You should use the results of Project 1 as a library function that returns the structure with the sign, exponent, and mantissa. - To calculate the restored value, you should write and add to the library a function that implements the following formula VALUE =1S1.M2E127, where S is the sign bit (0 or 1 ), M is the mantissa (0000002 to 1111112) and E is the biased exponent (000000002 to 111111102). - To get full credit for the project, it must be organized into three files: the main program, the library module with implementations of IEEE 754 conversion functions, and the header file. Work on the project task by task. SUBMISSION, GRADING, AND ACADEMIC INTEGRITY The project must be submitted on Blackboard. You have three attempts; please read Programming Assignments Requirements and Recommendations on Blackboard for suggested use of the attempts and submission package. Please read Programming Assignments Requirements and Recommendations on Blackboard for the grading rubric. Please read Programming Assignments Requirements and Recommendations on Blackboard for a strong warning on cheating. RECOMMENDED STEPS OF DEVELOPMENT TASK \# 1. LINKED LISTS Start with the generating of random numbers with the function rand ( ). You may find an example in the lecture handouts. But this time the result should be a float number in the range of [100.0,100,0]. At this stage, you can hardcode the desired amount of positive numbers. I recommend you set it to at least 100 to make sure that your program can generate numbers in each of the four categories given in the description. At this stage, you can hardcode the desired amount of positive numbers. I recommend you set it to at least 100 to make sure that your program can generate numbers in each of the four categories given in the description. To add a new node to the proper linked list you may use the lecture handout or textbook examples but note that the new nodes must be added at the beginning of the lists. TASK \#2. FILES At this stage, you can hardcode the file names and simplify the nodes, so they hold only a number and a pointer. Your program must save four linked lists in four different files. TASK \#3. COMMAND LINE ARGUMENTS Function main () can take string arguments from the command line. Your program must be run with two arguments: the desired amount of positive numbers to stop random generating and the files' extension. You must consider the situation when the user missed the arguments. It will be your choice to use the default values or stop execution with a message to the user. The example of command line arguments you can find in the textbook or the handouts to the lecture about files. The example of command line arguments you can find in the textbook or the handouts to the lecture about files. TASK \#4. LINKING TO PROJECT 1 Modify your Project 1, so it has no main () function but a collection of functions including one that receives a real number and returns a structure that holds IEEE 754 representation as sequences of 0 s and 1 s with the fields: sign, exponent, mantissa. Use typedef to define this structure as a new type in a header file. The header file must have the same name as the file with functions from Project 1 and the extension. .h. The header must also have the prototypes of all functions that can be used by the third file. For example, if your modified Project 1 file has the name p1_lib.c, then the header file must have the name p1_lib. h. Both p1_lib. c and the main Project 2 file must include the new header file (note double quotes): \#include "pl_Iib.h" All files must be in the same directory, then you can compile two source code files together: gcc p2-main.c p1_lib.c -o proj2 TASK \#5. ELABORATING ON THELINKED LIST NODES Add a structure with IEEE 754 representation and a 11 oat field to your nodes. The new fields must be calculated before the node is added to the list. Use your Project 1 library to calculate the IEEE 754 representation for the random number. Add a new function to your library that restores the decimal value from the IEEE 754 representation. Use this function to calculate and save the restored number in the field. If the restored number is not equal to the original number, the node should not be added but the error message should be printed to stder r. 88./pl Input a real number: 1 The IEEE 754 Single Precision is Sign: 1 Mantissa (24 bit): 100000000000000000000000 Exponent: 01111111 88./p1 Input a real number: 35e10 The IEEE 754 Single Precision is Sign: 0 Mantissa (24 bit): 101000101111101101000000 Exponent: 10100101 88./p1 Input a real number: 45000000.08 The IEEE 754 Single Precision is Sign: 0 Mantissa (24 bit): 101010111010100101010000

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

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

Are questions anonymous?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago