Question
Hi, for this question I just want to see if I got right the steps of my C++ program. Below are the steps and the
Hi, for this question I just want to see if I got right the steps of my C++ program. Below are the steps and the code. Thanks.
#include
using std::cout;
using std::cin;
using std::endl;
int readArray(int, int[]);
int main()
{
const int MAX_SCORE = 50;
int score[MAX_SCORE];
int nScores = 0;
cout
nScores = readArray(MAX_SCORE, score);
cout
system("pause");
return 0;
}
int readArray(int MAX_SIZE, int arrayToBeFilled[])
{
int nEntries = 0;
for (int i = 0; i
{
char buf[100];
cin >> buf;
arrayToBeFilled[i] = atoi(buf);
if (arrayToBeFilled[i] 100)
{
i -= 1;
continue;
}
else if (buf[0] == 'q' || buf[0] == 'Q')
break;
else
nEntries++;
}
return nEntries;
}
LAB 6: Working With Arrays [ Array.cpp ] STEP 1 of 5: Create And Fill An Array Write the Array.cpp program as listed below. It uses an array to store up to 50 test scores from the keyboard. Scores are integer numbers as low as O, and up to and including 100. Note that the program reads console input directly into a numeric variable. Run this, and see what happe if you enter text when prompted for numeric input -- it's not pretty! Remember that our convention is to not read numerics directly into cin. Be sure to follow all of the programming conventions for this course, even if they are not followed in the sample code provided in this writeup! #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started