rodaira
Active Member
- Messages
- 1,677
- Joined
- Apr 13, 2007
- Messages
- 1,677
- Reaction score
- 312
- Points
- 41
masta kasi buka kelas C programming plak...ada student ni...![]()
Tak mau lah...niat nak belajar pun dah salah...
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
masta kasi buka kelas C programming plak...ada student ni...![]()
Rileks bro, aku ni dah nak masuk umur 40an dan tak pandai IT dan part time student pulok.
// from the keyboard and then calculates and outputs* the average score
// as well as the highest and lowest score. There will be a maximum of 100 scores.
*
*
#include <iostream>
using namespace std;
*
*
*
float findAverage (int [], int);* // finds average of all grades
int** findHighest (int [], int&);* // finds highest of all grades
int** findLowest* (int [], int&);* // finds lowest of all grades
*
int main()
*
{
****const int SIZE=100;
****int* grades[SIZE];* // the array holding the grades.
****int* numberOfGrades; // the number of grades read.
****int pos; // index to the array.....LIKE COUNT
****int size;
****float avgOfGrades;// contains the average of the grades.
****int highestGrade;// contains the highest grade.
****int lowestGrade;// contains the lowest grade.
*
****// Read the values into the array
****pos = 0;
****cout << "Please input a grade from 1 to 100, (or -99 to stop)" << endl;
****cin* >> grades[pos];
*****
****//findAverage ([], size);
*
****while (grades[pos] != -99)
****{
*
********// Fill in the code to read the grades: 4 scores
********cout << "enter test score number " << (pos + 1) << ":";
********cin >> grades[pos];
******
*
****numberOfGrades = grades[pos];* // Fill blank with appropriate identifier
*
****// call to the function to find average
****avgOfGrades = findAverage(grades, numberOfGrades);
****cout << endl << "The average of all the grades is " << avgOfGrades << endl;
*
****//* Fill in the call to the function that calculates highest grade
*****
****highestGrade = findHighest(grades, size);
****cout << endl << "The highest grade is " << highestGrade << endl;
*
****// Fill in the call to the function that calculates lowest grade
*
****lowestGrade = findLowest(grades, size);
****// Fill in code to write the lowest to the screen
****cout << endl << "The highest grade is " << lowestGrade << endl;
*
****return 0;
**
*
//****************************************************************************
//******************************** findAverage
//
// task:********* This function receives an array of integers and its size.
//*************** It finds and returns the average of the numbers in the array
// data in:****** array of floating point numbers
// data returned: avarage of the numbers in the array
//
//****************************************************************************
*
float findAverage (int array[], int size)
{*
****float sum = 0;** // holds the sum of all the numbers
*
****for (int pos = 0; pos < size; pos++)
********sum = sum + array[pos];
*
****return (sum / size);* //returns the average
***********
**
*
//****************************************************************************
//******************************** findHighest
//
// task:********* This function receives an array of integers and its size.
//*************** It finds and returns the highest value of the numbers in
//*************** the array
// data in:****** array of floating point numbers
// data returned: highest value of the numbers in the array
//
//****************************************************************************
*
int** findHighest (int array[], int& size)
{
***// Fill in the code for this function
****const int SIZE=100;
****int highest;
****int grades[SIZE];
****highest = grades[0];
****for (int pos = 1; pos < SIZE; pos++)
****{
*******if (grades[pos] > highest)
**********highest = grades[pos];
******
****return highest;
**
*
*
//****************************************************************************
//******************************** findLowest
//
// task:********* This function receives an array of integers and its size.
//*************** It finds and returns the lowest value of the numbers in
//*************** the array
// data in:****** array of floating point numbers
// data returned: lowest value of the numbers in the array
//
//****************************************************************************
*
int** findLowest(int array[], int& size)
{
***// Fill in the code for this function
****const int SIZE=100;
****int lowest;
****int grades[SIZE];
****lowest = grades[0];
****for (int pos = 1; pos < SIZE; pos++)
****{
*******if (grades[pos] < lowest)
**********lowest = grades[pos];
******
****return lowest;
*
* ini coding untuk exam scores![]()
Ini coding C++, bukan C.