Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C language, do the following: code should ... *malloc space for 2 dimensional pointer *if null, abort code *be segmentation fault free *be memory

In C language, do the following:

image text in transcribed

image text in transcribed

code should ...

*malloc space for 2 dimensional pointer

*if null, abort code *be segmentation fault free

*be memory leak free

*size of 2d array must be inputted, not hard coded

*find quadrants in separate function

Thanks SO MUCH for your help! You are to write a C program that will read from a file, one or more sets of x,y coordinates. The numbers at the top of the file is for how many pairs of coordinates are their in the file. Each set of coordinates is part of a Cartesian system. A Cartesian coordinate system is a system that specifies each point uniquely in a plane by a pair of numerical coordinates. Your program will determine which quadrant each set belong. - Quadrants are often numbered 1st - 4th and denoted by Roman numerals: I(++), II (-+), III (-), and IV (+,-). Your program should contain a function that determines and returns which quadrant the x and y coordinate would be in. Listed below are a few of the steps you will need to take for this program: Use a C File Pointer (FILE*). The file you will need to open will be defined using a command line argument. You will need to open the file for reading. Please check if the file pointer is NULL or not before proceeding. If it is NULL , print error message and exit the program. Use fscanf to read two integer values from the input file. Those indicate the number of rows and columns of the 2 dimensional array for storing the coordinates. After this, use malloc to allocate memory for a 2 dimensional pointer or pointer to pointer of type integer. You will use fscanf again to read each set of coordinates. Once you have read a set of coordinates call the function you wrote to determine the quadrant it belongs by passing those coordinates and print the appropriate output. Below is an example input file. 42 -12 12 2-1 -1-2 Based on this input file the output would be as follows: X and Y are in Quadrant II X and Y are in Quadrant I X and Y are in Quadrant IV X and Y are in Quadrant

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 Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

4. What actions should Bouleau & Huntley take now?

Answered: 1 week ago