Could use some, no, a LOT of help on my arrays assignment (C)

In summary, The project requires writing a program to input, compute, and display various statistics for a list of test scores. The program should be able to handle up to 30 positive test scores and use -1 as a sentinel value. The output should include the original test scores, sorted test scores in descending order, count, highest, average, median, and standard deviation. It should also print the percentage of students who passed the class with a grade of 70% or higher. For extra credit, the program should be able to print the student ID, test score, and letter grade in descending order according to the test score. This can be achieved by using two arrays, one for student ID and one for test score, and implementing
  • #1
clook
35
0
Here's the project sheet. it's due tomorrow btw

"Write a program to input, compute, and display various statistics for a list of test scores of up to 30 positive test scores of type double. You shall input an array with the following values as one of your test cases (use -1 as a sentinel value):

73.5 83.0 58.0 0.0 95.0 69.0 83.2 99.0 74.5 80.0
90.0 92.0 60.0 77.5 66.5

Your program shall display the original test scores (max 8 values per line), sorted test scores in descending order (max 8 values per line), count (number of test scores), highest, average, median, and standard deviation in a readable format using one digit after the decimal place. It then finally prints the percent of the students that passed the class (70% or better). Write down the pseudocode before attempting your code on the computer.

Extra credit: You can earn up to 5 additional points if you are able to print a student id, test score, and a letter grade in descending order according to the test score. Assume that the first test score belongs to student 1, second test score belongs to student 2, and so on. Use a standard grading scale of 90%, 80%, 70%, and so on. See sample output below. Hint: You either use two arrays or a structure.

Id Score Grade
8 99.0 A
5 95.0 A
. . .
4 0.0 F
"


i have this, a simple array s tructure so far:

Code:
#include <stdio.h>
#define MAXARR 30

main()
{
	int
		arr[MAXARR],i,counter,value,no_of_elements,max;
	/*--------------------------------------------------------------------*/
	/* Input routine  User is required to enter values from keyboard      */
	/*--------------------------------------------------------------------*/

	printf("\f");
	counter = 0;
	printf("Do not enter more than %d values please\n\n",MAXARR);
	printf("Please enter value (-1 to quit:   ");
	scanf("%d",&value);
	while (value != -1)
	{
		arr[counter] = value;
		printf("Please enter value (-1 to quit):   ");
		scanf("%d",&value);
		counter = counter + 1;
	}

	/*--------------------------------------------------------------------*/
	/*  output routine.  elements and no. of elements is displayed        */
	/*--------------------------------------------------------------------*/
	no_of_elements = counter;
	printf("%d values were enetered\n",no_of_elements);
	printf("these values are:  \n");
	for(i=0;i<no_of_elements;i=i+1)
		printf("%d  ",arr[i]);

	/*-------------------------------------------------------------------*/
	/* Findmax routine.                                                  */
	/*-------------------------------------------------------------------*/
	max=arr[0];
	for(i=1;i<no_of_elements;i=i+1)
		if(arr[i]>max)
		max = arr[i];

	printf("\n\nThe largest element stored in the array is: %d\n",max);

i'm totally lost. I'm not sure how to modify this to make it work to the specifications of the project, also, I'm not sure how to implement the sort and searching and standard deviation to it.

if it's too much, i am willing to pay for someone to walk me through it step by step. i simply don't have enough time!
 
Physics news on Phys.org
  • #2
how about using two arrays one for the student ID and one for the score

Then bubble sort the scores

Arrange student IDs

then finally group them.
 
  • #3



Hello, it seems like you are struggling with your arrays assignment. Don't worry, you are not alone and I am here to help. The first thing you should do is to take a deep breath and relax. Panicking will not help you in this situation. I understand the importance of time management and meeting deadlines. However, it is also important to understand the concepts and principles behind the assignment rather than just trying to complete it in a rush.

Let's break down the project sheet and see what is required from you.

1. Input, compute, and display various statistics for a list of test scores:
- This means that you need to write a program that takes in a list of test scores and performs calculations to find various statistics such as the highest, average, median, and standard deviation.

2. Input an array with the following values as one of your test cases:
- The array should have a maximum size of 30 and should only contain positive test scores. The use of a sentinel value of -1 is mentioned, which means that the user can terminate the input process by entering -1.

3. Display the original test scores and sorted test scores in descending order:
- This means that after taking in the test scores, you need to display them in the same order as they were entered and then display them in descending order.

4. Count, highest, average, median, and standard deviation:
- These are the statistics that you need to compute and display. The count refers to the number of test scores entered, highest is the highest test score, average is the average of all the test scores, median is the middle value of the sorted test scores, and standard deviation is a measure of how spread out the test scores are from the average.

5. Percent of students that passed the class:
- This is an extra credit task and can earn you up to 5 additional points. You need to calculate the percentage of students that passed the class (70% or better) based on the test scores entered.

6. Extra credit task:
- This task involves printing the student ID, test score, and letter grade in descending order according to the test score. This means that you need to create a structure or use two arrays to store this information and then display it in descending order.

Now that we have a better understanding of what is required, let's go through the pseudocode before attempting the code on the
 

Related to Could use some, no, a LOT of help on my arrays assignment (C)

1. What are arrays in C and how do they work?

Arrays in C are a data structure that allows you to store a collection of elements of the same data type. They work by allocating a contiguous block of memory to store the elements, and each element is accessed using an index number starting from 0.

2. How do you declare an array in C?

To declare an array in C, you use the following syntax: data_type array_name[array_size]; For example, to declare an array of integers with 5 elements, you would use int numbers[5];

3. How do you access elements in an array in C?

You can access elements in an array in C using the index number. For example, to access the third element in an array called "numbers", you would use numbers[2]; Keep in mind that array indexing starts at 0, so the first element would be accessed using numbers[0];

4. Can you change the size of an array in C?

No, the size of an array in C is fixed at the time of declaration and cannot be changed during runtime. If you need to store more elements in an array, you would need to declare a new array with a larger size and copy the elements from the old array to the new one.

5. How do you initialize an array in C?

You can initialize an array in C at the time of declaration using curly braces. For example, int numbers[5] = {1, 2, 3, 4, 5}; This would create an array with 5 elements and initialize them with the given values. You can also initialize the array with a single value, which would set all elements to that value. For example, int numbers[5] = {0}; would create an array with 5 elements, all set to 0.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
951
  • Engineering and Comp Sci Homework Help
Replies
3
Views
683
  • Engineering and Comp Sci Homework Help
Replies
17
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
21
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
905
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top