A
arnuld
i do not have any problem here. i solved the problem but i wanted to
know the views of you. please look at it from a newbie's perspective:
problem: define a table with names of months of the year & the number
of days in each month. write out that table. do this using: 2 arrays, 1
for months & 1 for days.
this is the solution i have created:
#include <iostream>
#include <string>
const int arr_size = 12;
std::string arr_mon[arr_size] =
{"jan", "feb", "mar", "apr", "may", "june", "july", "aug", "sep",
"oct", "nov", "dec"};
int arr_days[arr_size] =
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
30, 31};
void print_2_arrays(std::string month[], int days[])
{
for(int i=0; i < arr_size; ++i)
{
std::cout << month
<< "\t"
<< days <<"\n";
}
std::cout << "=========================================\n";
}
int main() {
print_2_arrays(arr_mon, arr_days);
}
know the views of you. please look at it from a newbie's perspective:
problem: define a table with names of months of the year & the number
of days in each month. write out that table. do this using: 2 arrays, 1
for months & 1 for days.
this is the solution i have created:
#include <iostream>
#include <string>
const int arr_size = 12;
std::string arr_mon[arr_size] =
{"jan", "feb", "mar", "apr", "may", "june", "july", "aug", "sep",
"oct", "nov", "dec"};
int arr_days[arr_size] =
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
30, 31};
void print_2_arrays(std::string month[], int days[])
{
for(int i=0; i < arr_size; ++i)
{
std::cout << month
<< "\t"
<< days <<"\n";
}
std::cout << "=========================================\n";
}
int main() {
print_2_arrays(arr_mon, arr_days);
}