Write a function that will return the area of a trapezoid

Assignment Help C/C++ Programming
Reference no: EM13987880

Directions:

Answer all questions and follow the rules below.

Please attach one single text file (not Word or other formats) with all your answers.

Do not send multiple files!

I just need the answer ... do not send program output, only the C source code ... and again, all in one single text file.

Understand that if I ask for a function, all I am looking for is that function in your answer ... not a complete program that includes a main function ... I just need to see your function as the answer.

If I ask for a program, then I am looking for a main function that calls one or more functions (include the functions).

If I ask for a code segment, then all I am looking for is just the code needed to answer the question.

Rules:

1. You many use your book and notes

2. Quality, Re-usability, Maintainability, Readability, and Efficient code will be stressed in addition to correctness.

3. Same rules and standards apply as your homework assignments (comments, headers, style, ...)

4. Use your computer to compile your code and test it out

5. Contact me if you have questions or state your assumptions

Questions:

1) Use the link below for the background needed to create two functions that work with a Trapezoid

https://www.mathsisfun.com/geometry/trapezoid.html

a) Write a function that will return the area of a trapezoid
b) Write a function that will return the perimeter of a trapezoid

2) Write a function

int frequency (int theArray [ ], int n, int x)

that counts the number of times the item x appears among the first n elements of theArray and returns that count as the frequency of x in theArray. Use integers for everything!

For example, if the array being passed contained the values 5, 7, 23, 8, 23, 67, 23

... and n was 7 and x was 23, then it would return a value of 3 since 23 occurs 3 times within the first 7 elements of the array.


3a) Represent the mathematical operation: max (x, y, w, z) as a C function. This is, write a function that is passed 4 integer values that returns the largest value of those four parameters. For example, max (5, 2, 4, 1) would return 5 since it is the largest value of the four parameters.

3b) Rewrite the mathematical operation: max (x, y, w, z) as a single statement using the conditional expression operator. For example, max (x, y) would be:

max = (x > y) ? x : y;

Hint: You will have more than one conditional expression operator (?) in your answer, and it would help to use boolean logic operations that were covered in Week 3.

4) Given the following test scores and grade equivalents, write a function which is passed a score, and returns a letter grade based on the score entered. A number less than 0 or greater than 100 is invalid.

            Score                    Grade

            ------                   -----

            90-100                   A

            80-89                    B

            70-79                    C

            60-69                    D

            0 -59                    F

5) Write a function that is passed an array of characters containing letter grades from our previous question, and prints a report that shows the total number of occurrences of each letter grade. Your function should accept both lower and upper case grades, for example, both 'b' and 'B' should be bucketed into your running total for B grades. Any grade that is invalid should be bucketed as a grade of 'I' for Incomplete.

You must use a switch statement, and your function should accept an array of any size. Feel free to pass in the array size as parameter so you know how many grades you'll need to check in your loop.

For example, if you passed a function the following array:

char grades [ ] = {'A', 'b', 'C', 'x', 'D', 'c', 'F', 'B', 'Y', 'B', 'B', 'A'};

   It would print:

       Grade        Total

       -----        -----

         A            2

         B            4

         C            2

         D            1

         F            1    

         I            2

6) Write a program that contains a main function and three other functions that will return various attribute information about an array of floating point numbers:

array_sum - total sum of all array elements
array_avg - average of all array elements
array_min - the smallest number of the array elements

The main function should print the values returned from each function at the end of the program.

7) Write a function that raises an integer to a positive integer power.

Call the function x_to_the_n, taking two integer arguments x and n. Have the function return a long int, which represents the results of
calculating x to the nth power. Do not use the C pow library function.

Example: if x = 3 and n = 2, the function would return 9.

NOTE: Do not use recursion (since that version is in your lecture notes).

8) (Code Segment) The Federation has asked you to develop a program to keep track of its officers. A sample of the kind of information for each officer is shown below.

        Name: Mr. James Tiberius Kirk

        Date of Birth:  March 22, 2233

        Address:  23 Falling Rock,

                  Riverside, Iowa 52327-0021

                  Planet Earth

        Rank: Captain

        Ship: USS Enterprise

        Nickname: Jim

        Starfleet ID: 02341232

        Hourly Pay: 456.78

        Favorite Saying: "Bones???"

        Starting Stardate: 41153.7

        Martial Status:  Single

        Starfleet Graduation Date:  June 23, 2212

        Name: Mr. Leonard A. McCoy Jr.

        Date of Birth:  7/8/2227

        Address:  8745 South Road

                  Jackson, Mississippi 09201-0001

                  Planet Earth

        Rank: Chief Medical Officer

        Ship: USS Enterprise

        Nickname:  Bones

        Starfleet ID: 00034212

        Hourly Pay: 234.56

        Favorite Saying:  "He's dead Jim."

        Starting Stardate: 41151.8

        Marital Status:  Divorced

        Starfleet Graduation Date:  June 21, 2210

Provide the code need to DECLARE an array of structures given the above information. Don't write a program and don't worry about initializing the structure based on the information above.

Be careful on how you declare the members of a structure. Grading will be based on how the flexibility of your design (i.e., define many structures and have structures within structures if necessary).

Note: Don't go overboard such as having a structure with only one member just to create many structures.

Verified Expert

This solution provides an insight into the basic concepts in C programming. Several concepts of the C language including the functions are illustrated.

Reference no: EM13987880

Questions Cloud

Accretion of carrying amount of preferred stock : What guidance does the SEC provide for public companies with respect to the reporting of the "effect of preferred stock dividends and accretion of carrying amount of preferred stock on earning per share?
First calculate the portfolios returns : Assume that your cousin holds just one stock, Eastman Chemical Bonding (ECB), which he thinks has very little risk. You agree that the stock is relatively safe, but you want to demonstrate that his risk would be even lower if he were more diversified..
Find final temperature of the calorimeter after equilibrium : Find the final temperature of the calorimeter after equilibrium is reached. If the final temperature is 0oC, what fraction of the ice is melted?
Problem regarding the maintenance fees associated : Are there any maintenance fees associated with the account at either brokerage firm? Now assume that you have a margin account and the balance is $3,000. Calculate the interest rate you would pay if you borrowed money to buy stock.
Write a function that will return the area of a trapezoid : Write a function that will return the area of a trapezoid - Write a function that will return the perimeter of a trapezoid
Distinction between painting and sculpture : How does Frank Stella's non-rectangular canvases blur the distinction between painting and sculpture?
Overall purpose of the reproductive systems : Introduction: For this activity, you will develop a PowerPoint Presentation about human reproduction. Your presentation must include the following: overall purpose of the reproductive systems
Calculate the equivalent annual cost : Hayden Inc. has a number of copiers that were bought four years ago for $33,000. Currently maintenance costs $3,300 a year, but the maintenance agreement expires at the end of two years and thereafter the annual maintenance charge will rise to $9,300..
Problem regarding the company annual report : What evidence would help you evaluate whether or not a company does adequate cash planning? Is there any information not available in the company's annual report that would help you make this evaluation?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Pixels down the right of the window

The blue and red values of the pixels across the top of the window are all the same, where the blue is at its maximum value while red is at its minimum value. The green values of the pixels down the right of the window are all the same, where gree..

  Write a program to calculate existing angles and do if and

write a program to calculate existing angles and do if and then from this and to place fixed angles at certain position

  Write down program in c for matrix multiplication program

write down program in c for matrix multiplication. program must accept dimension of both matrices to be multiplied and

  How do the properties derived classes differ

How do the properties derived classes differ

  Compute and display the new balance

Write a complete C++ program that asks for the beginning balance and the number of checks written. Compute and display the new balance and the bank's service fees for the month.

  The fibonacci sequence

In the novel "The DaVinci Code", a scrambled version 13, 3, 2, 21, 1, 1, 8, 5 of the first eight Fibonacci numbers appear as one of the clues left by murdered museum curator Jacques Sauniere. In this assignment, we will do something related to t..

  Write a program that takes data a line at a time

Write a program that takes data a line at a time and reverses the words of the line

  Write a java class named mylinkedlist and implement it

void updateList(MyLinkedList otherlist) that will update the current list with a given otherlist. If an element in current list exists in the otherlist then replace (update) it, otherwise insert (add) it using the above insertSortNoDuplicate metho..

  Create a program that prompts a user for her name

A. Given a = 5, b = 1, x = 10, and y = 5, create a program that outputs the result of the formula f = (a b)(x y) using a single printf() function. B. Create a program that uses the same formula above to output the result; this time.

  Research paper on overloading operator

Write a 2 page research paper (excluding title and reference pages / double spaced) on overloading operators. Explain the concepts discussed in the textbook using at least an example not included in the textbook.

  Implement the bisection method for solving given equations

Implement the Bisection Method for solving equations. Use the following function: double root(double (*pf)(double x), double a, double b, int n).

  By a minimal interpretation that makes a formula

By a minimal interpretation that makes a formula true, we mean that if one atom is removed from the interpretation then the resulting interpretation does no longer make the formula true.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd