QuestionQuestion

QUESTION 1
1. Which of the following access the member myAge in a structure named student?
student >- myAge;
student.myAge;
student (myAge);
student [myAge]
10 points   
QUESTION 2
1. A structure consists of members which must all be the same type.
True
False
10 points   
QUESTION 3
1. A structure consist of one or more items that are referred to as "members"
True
False
10 points   
QUESTION 4
1. Which of the following is a properly declared structure ?
struct { int val; }
struct foo { int val; }
struct foo int val;
struct foo { int val; };
10 points   
QUESTION 5
1. Which is not a valid C Run Time Area?
Hash
Heap
Stack
Text

10 points   
QUESTION 6
1. Which operator connects the structure name to its member name?
*
.
->
None of the above

10 points   
QUESTION 7
1. Which run time area contains global and static variables?
text
data
stack
quere
10 points   
QUESTION 8
1. Which run time area is dynamic and allows you to create additional storage areas in it at run time?
data
text
heap
hash
10 points   
QUESTION 9
1. It is possible for a structure to have a member who has been declared as an Array
True
False
10 points   
QUESTION 10
1. It is possible for a struture to be declared with members who all share the same type (such as float).
True
False


C Programming
Questions:
1) Use the MAthisfun for the background needed to create two functions that work with a Trapezoid
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) (Function) 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) (Code Segment) 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. It should also check for invalid values (a number less than 0 or greater than 100).
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.

9) What compiler do you use in this class? Give me four things you like and/or dislike about our compiler ... any combination will work.
Your Compiler:
4 Likes and/or Dislikes:
1)
2)
3)
4)

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

1a)
float getTArea ()
{
float a,b,h,tArea;
printf("\nEnter side A of trapezoid 1: ");
    scanf ("%f", &a);
printf("\nEnter side B of trapezoid 1: ");
    scanf ("%f", &b);
printf("\nEnter height of trapezoid 1: ");
    scanf ("%f", &h);
tArea=((a+b)/2)*h;
return tArea;
}

2) float getTPerim ()
{
float s1,s2,s3,s4,tPerim;
printf("\nEnter side 1 of trapezoid 2: ");
    scanf ("%f", &s1);
printf("\nEnter side 2 of trapezoid 2: ");
    scanf ("%f", &s2);
printf("\nEnter side 3 of trapezoid 2: ");
    scanf ("%f", &s3);
printf("\nEnter side 4 of trapezoid 2: ");
    scanf ("%f", &s4);
tPerim=s1+s2+s3+s4;
return tPerim;
}

2) int frequency (int theArray [SIZE], int n, int x)
{
int cnt...

By purchasing this solution you'll be able to access the following files:
Solution.txt and Solution.docx.

$13.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats