I particular did not understand this line "const int num_months=12; ". I think the int refers to num_months is an integer, but what the const refers?
I have a question about my c++ homework. I did not understand one line code, which is " const int num_months=12;
string name[num_months]={"january", "march", "may"}; int days [num_months]={31, 28, 20};".
I particular did not understand this line "const int num_months=12; ". I think the int refers to num_months is an integer, but what the const refers? Please explain, thank you.
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
const int num_months=12;
string name[num_months]={"january", "march", "may"};
int days [num_months]={31, 28, 20};
for (int month=0; month<num_months; month++)
{
cout<<setw(9)<<left<<name[month]<<"has";
cout<<days[month]<<"days. /n";
}
return 0;
}
Step by step
Solved in 2 steps with 2 images