Question
using multidimensional arrays in C++ It said I did not declare the 2 dimensional array, but it has been initialized, what do I have to
using multidimensional arrays in C++
It said I did not declare the 2 dimensional array, but it has been initialized, what do I have to add to declare it, I thought ive already done that. with the "int rate"
#include using namespace std;
int main() { // Declare two dimensional array here int rate[5][5] ={ {30, 60, 88, 115, 140}, {26, 52, 70, 96, 120}, {24, 46, 67, 89, 110}, {22, 40, 60, 75, 88}, {20, 35, 50, 66, 84}}; for(int age=0;age<5;age++){ for(int numDays=0;numDays<5;numDays++) cout << rate[age][numDays] << " "; } cout << endl; // Declare other variables int numDays; int age; int QUIT = 99; // This is the work done in the getReady() function // Perform a priming read to get the age of the child cout << "Enter age of child or 99 to quit: "; cin >> age; while(age != QUIT) { // This is the work done in the determineRateCharge() function // Ask the user to enter the number of days cout << "Enter number of Days: "; cin >> numDays; // Print the weekly rate cout << "rate is $" << rate[age][numDays] << endl; // Ask the user to enter the next child's age cout << "Enter age of child or 99 to quit: "; cin >> age; } // This is the work done in the finish() function cout << "End of program" << endl;
return 0; } // End of main() function
Step 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