avr39ripe

cppDaysInMonthArray

Mar 23rd, 2021
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     const int monthSize{ 12 };
  6.     int days[monthSize]{ 31,28,31,30,31,30,31,31,30,31,30,31 };
  7.  
  8.     int month;
  9.  
  10.     std::cout << "Enter month number: ";
  11.     std::cin >> month;
  12.  
  13.  
  14.     std::cout << "In month number " << month << " there are " << days[month - 1] << " days\n";
  15.  
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment