Question

write a simple program to receive 6 students’ mid-term grades, store them in array and sort...

write a simple program to receive 6 students’ mid-term grades, store them in array and sort them in ascending order?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Since the data type of grades are not mentioned, i am assuming the grades to be rounded integers.

Program:

#include <iostream>
using namespace std;

int main()
{
int arr[6],i,j,temp;
for(i=0;i<6;i++) //Getting the grades of 6 students
cin>>arr[i];
for(i=0;i<5;i++){ //Sorting the array
for(j=i+1;j<6;j++){
if(arr[i]>arr[j]){
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
cout<<"The ascending order of students mid-term grades:\n"; //Printing the resulting ascending order
for(i=0;i<6;i++)
cout<<arr[i]<<"\t";
return 0;
}

Output:

10 9 6 8 7 8 The ascending order of students mid-term grades: 7 8 9 10 |.. .Program finished with exit code 0 Press ENTER to

Add a comment
Know the answer?
Add Answer to:
write a simple program to receive 6 students’ mid-term grades, store them in array and sort...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a MATLAB program to do the following: Receive 5 input values and store them into...

    Write a MATLAB program to do the following: Receive 5 input values and store them into a single 1x5 array Receive another 2 input values and store them into a separate 1x2 array Add the scalar value 5 to each array value Store each array into 2 cells within one cell array Also store each array as separate elements within one struct

  • c++ Write a program that reads 10 marks of type float, store them in an array,...

    c++ Write a program that reads 10 marks of type float, store them in an array, then the program will 4 determine the number of marks greater than the average. Write a program that reads 10 marks, store them in an array, then the program will print the .5 array in reverse order.

  • 2) Write a method to take an array of grades (float array) and output a histogram...

    2) Write a method to take an array of grades (float array) and output a histogram of those grades (array) 3) Write loop(s) to fill a 20 x 20 array with a multiplication table 4) linder length :double radius: double + Cylinder O Cylinder (len:double, rad: double) tLength (len:double): void etRadius (wid: double): void etLength ): double etRadius): double SufArea O: double etVolume (): double (show javadoc for all problems) Write the Constructor that takes two parameters Write the setRadius...

  • Write a JAVA program to sort a given array of integers (1 Dimensional) in ascending order...

    Write a JAVA program to sort a given array of integers (1 Dimensional) in ascending order (from smallest to largest). You can either get the array as input or hardcode it inside your program.

  • C programming Strictly - Write a program to sort an array of integers via arrays of...

    C programming Strictly - Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. Problem 1 (68 points): Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. The code should contain the following functions: 1)to randomly generate an array of integer numbers; 2) to allocate memory and build the arrays of pointers as shown in the figure...

  • C programing Write a program to sort numbers in either descending or ascending order. The program...

    C programing Write a program to sort numbers in either descending or ascending order. The program should ask the user to enter positive integer numbers one at a time(hiting the enter key after each one) The last number entered by the user should be -1, to indicate no further numbers will be entered. Store the numbers in an array, and then ask the user how to sort the numbers (either descending or ascending). Call a function void sortnumbers ( int...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • You are to write a program which will ask the user for number of students (dynamic...

    You are to write a program which will ask the user for number of students (dynamic array of class Student). For each student, you will ask for first name and number of grades (dynamic array of grades as a variable in Student). **The program should give the student random grades from 0-100** Find the averages of each student and display the information. **Display name, grades, and average neatly in a function in the Student class called Display()** Sort the students...

  • You are to write a program which will ask the user for number of students (dynamic...

    You are to write a program which will ask the user for number of students (dynamic array of class Student). For each student, you will ask for first name and number of grades (dynamic array of grades as a variable in Student). **The program should give the student random grades from 0-100** Find the averages of each student and display the information. **Display name, grades, and average neatly in a function in the Student class called Display()** Sort the students...

  • Please write a Java program that does the following: Create an array of 100 integers. Store...

    Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT