004-001-008
Array Declaration: Weekday List
Easy
Problem Description
Array Declaration: Weekday List
In this problem, you will create a program that reads the number of weekdays and each weekday name from standard input, stores them in an array variable days, then displays each element with its index and the total element count to standard output.
Learning Objective: Declare array variables and store/access elements
Create a program to store and display weekdays in an array. Learn array declaration and initialization.
Input
N
day1
day2
...
dayN
- Line 1: Number of days N (1 ≦ N ≦ 7)
- Lines 2 to N+1: One day name per line
Output
Weekdays:
days[0] = day1
days[1] = day2
...
Total: N days
Specifications
- Read N from input and declare array days of size N
- Read N day names and store them in the array
- Display each element with its index
- Display the array length
Example
Input:
3
Monday
Tuesday
Wednesday
Output:
Weekdays:
days[0] = Monday
days[1] = Tuesday
days[2] = Wednesday
Total: 3 days
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up