Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Please read entire post

Part 1 :

Modify the code below so that it uses heap memory to store percentage grades in the range from 0 to 100 (inclusive). The program should allow the user to indicate when he or she is done entering grades (since the user may not have grades to fill the whole array).

When the user is done entering grades, the program should print out the grades entered by the user. Be sure to free the head memory before the program ends.

Part 2:

Modify the below code from so that it uses custom functions to add grades to the array, print the grades entered, calculate the average grade (arithmetic mean, not letter grade), and report the highest and lowest grade entered. This version of the program does not need to use heap memory, though you are welcome to do so.

The program should allow the user to indicate when he or she is done entering grades (since the user may not have grades to fill the whole array).

When the user is done entering grades, the program should print out the grades entered by the user. The program should also display the average grade, highest grade, and lowest grade.

#include "stdio.h"

int main(void)

{

//initialize array

int arr[100];

//initialize variables

int i=0, j=0, n=0;

//infinite loop which will stop when user enters -1

while(n != -1)

{

printf("Enter percentage grade(0-100). Enter -1 to stop: ");

//read grade

scanf("%d",&n);

//if user entered grade is not -1

if(n != -1)

{

//save it to array

arr[i++] = n;

}

//if user entered -1, then exit this loop

else

{

break;

}

}

printf("\n\nThe grades are: \n");

//loop which will iterate till no:of user entered grades

for(j=0; j

{

//print the grade

printf("%d ",arr[j]);

}

return 0;

}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93087536

Have any Question?


Related Questions in Computer Engineering

On the spot courier services grew and changed over the

On the Spot courier services grew and changed over the years. At first, Bill received requests for package pickups on his mobile phone, recorded that information in a log, and would then drive around to retrieve all the ...

Stacksthere are two main operations associated with stacks1

Stacks There are two main operations associated with stacks; 1) putting things on the stack which is referred to as push, 2) taking things from the stack which is referred to as pop. We can create a stack using linked li ...

A soda vendor at aloha stadium noticed that during rainbow

A soda vendor at Aloha Stadium noticed that during Rainbow Warrior football games that more soda is being served the warmer the temperature during game time. Based on 40 home games covering the past 5 years, the vendor e ...

You work in a veterinarians office and need to organize the

You work in a Veterinarian's office and need to organize the data on pets that you treat. In your database, you want to keep track of the following information: Customer information: Name Address City State ZIP Phone # Y ...

Question introduction to management information systemsread

Question: Introduction to Management Information Systems Read at least three (3) academically reviewed articles on Management Information Systems and complete the following activities: 1. Summarize all three (3) articles ...

Listen to or read the transcript of this podcast

Listen to (or read the transcript of) this podcast (https://www.stlouisfed.org/education/economic-lowdown-podcast-series/episode-16-elasticity-of-demand) from the Federal Reserve Bank of St. Louis. describe your experien ...

Question suppose we run dfs on a undirected graph g that

Question : Suppose we run DFS on a (undirected) graph G that has edge weights and is connected (there is a path connecting any two vertices of G). (a) Prove that the DFS tree is a spanning tree of G. (b) Recall that the ...

1 a consumer has 300 to spend on goods x and y the market

1. A consumer has $300 to spend on goods X and Y. The market prices of these two goods are Px $15 and Py $5. a. What is the market rate of substitution between goods X and Y? b. Show how the consumer's opportunity set ch ...

Command to define an environmental variable name time with

Command to define an environmental variable name "time" with initial value "11:00PM". (Unix)

You randomly sample 50 theaters in the united states you

You randomly sample 50 theaters in the United States. You ask those theaters how much they charge for a large popcorn, and you get a sample mean of $6. Then, you make confidence interval using this data with the lower li ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As