Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Can anyone please try number 3? You MUST use C. For example: For example: Given the arrA: {ch,a,A,N cat, jump, rep, c} and the arrB:

image text in transcribedCan anyone please try number 3? You MUST use C.

For example: For example: Given the arrA: {"ch","a,"A,N cat", "jump", "rep", "c"\} and the arrB: {"3", "at", "ch", "ed", "I", "hat" } Given the 4220 array matrix1: {{1,1},{1,1},{1,1},{1,1}} findelements[arra, 7 , arrB, 6, "chat", result) should put the values 0,1 in result (6, 5 will also work, but calculateAreaShoelace (4, matrix 1,1) returns 2.0 (area of a triangle with the second point removed) not 0,5 ) calculateAreaShoelace (4, matrix1,4) returns 4.0 (area of a square as 4 is an invalid index) findElements[arrA, 7, arrB, 6, " AlN, result) should put the values 2,4 in result calculateAreaShoelace (4, matrix 1,0) retums 2.0 (area of a different triangle with the first point removed) findElements(arrA, 7, arrB, 6,!A, result) should put the values 1,1 in result Note that the area can be zero if the points are all in a straight line or there are not enough points to form findelements(arrA, 7 , arrB, 6,N CMMPT 3", result) should put the values 1,0 in result for partial match a polygon. You can assume that the row argument is correct for the array, and the points in the 2D array findElements[arrA, 7, arrB, 6, "hat ", result) should put the values 1,5 in result for partial match are arranged in a clockwise or anticlockwise manner (required for the Shoelace Formula to work). You can findElements(arrA, 7 , arrB, 6 , "chach", result) should put the values 1,1 in result because two partial also assume that the number of points will not be more than 128. The index can be invalid (negative or matches with extra characters in-between should not be confused with an exact match larger than row-1 and if that is the case it means no row is being removed. findElements(arrA, 7,arrB,6,, result) should put the values 1,1 in result Do not use dynamic arrays and the keyword continue in your answer (if you use any of those you get 0 for You can assume all elements (estrings) in the first and second arrays have at least one character and up this question). Your answer must first calculate S1, then S2, then the area (failure to do so will also get 0 ). to 63 characters, and there is no repetition within the same array. Letters are case-sensitive. Only include the function definition (and your helper functions, if any) in the source file and name it as Only include the function definition (and your helper functions, if any) in the source file and name it as a1_question3.c. a1_question2.c. Do not use recursion in your answer. Coding Style [4 marks] Question 3 [6 marks] Your program should be properly indented, have clear and meaningul variable names (e.g., no single- In mathematics there are formulas for calculating the area of a polygon formed by any number of points. letter variable names except loop iterators) and enough white space and comments to make it easy to One popular formula is called "the shoelace Formula": read. Named constants should be used where appropriate. Each line of code should not exceed 80 characters. White space should be used in a consistent manner. To help you to get into the habit of good coding style, we will read your code and marks will be deducted if your code is not styled properly. Using the Makefile and Other Supplied Files The Makefile provided in this assignment is used by a command in the CSIL machines called "make" to quickly compile your code. It is especially useful if you have multiple source files. To use it, type the following command in the prompt (make sure you are in the directory with all the files of Assignment 1): $ make test1 The example above illustrates how Question 1 is compiled into an executable called "test1" when using Makefile. Replace the "test1" with "test2", "test3", wetc. for other questions. You can then run the executable by typing "./test1" to test your code for Question 1 . If you make changes to your code, use the make command again. You can also use "make all" if you want to compile all your code at once. Write a function that takes in the number of rows (number of columns is fixed at 2) of a 2D array of ints, The test files (test1.c, test2.c, ...etc.) are provided in this assignment for you to test your code. Each the array itself, an integer as the index, and calculates the area of the polygon formed by the points typically contains a main function along with other tester functions and/or calls. You can modify them to represented in the 20 array with the row indicated by the index removed. Use this function header: further test your code, but do not submit these test files because we will be using our test files that are float calculateAreashoelacefunsigned int rows, int points[][2], int index) similar but not identical to grade your assignment. This makes sure that your code is not written to produce hard-coded output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions