Professional Documents
Culture Documents
LAB 10-In Lab Tasks PDF
LAB 10-In Lab Tasks PDF
Learning Objectives
In today’s lab, you will practice;
1. Declaring and initializing one-dimensional arrays.
2. Inserting values into and printing values out of one-dimensional arrays.
Practice Questions
You can practice the following problems in this lab.
Task 1.1 Declaring One-Dimensional Arrays
Write a C++ program, which declares;
• Integer type array of ‘10’ Indexes
• Float type array of ’15’ Indexes
• Double type array of ‘20’ Indexes
• Character type array of ‘25’ Indexes
Your program should calculate and print the size of each array. Your program should have the
following interface.
• Integer type array of size ‘6’. Initialize each index of array with ‘12’ at the Time of
Declaration.
• Float type array of size ‘5’. Initialize each index of array with ‘0.5’ at the Time of
Declaration.
• Character type array of size ‘4’. Initialize each index of array with ‘a’ at the Time of
Declaration.
Your program should display the values stored in these arrays using the following format.
Integer array : 12 12 12 12 12 12
Float array : 0.5 0.5 0.5 0.5 0.5
Character array : a a a a
Task 1.3 Inserting Values into and Printing Values out of One-Dimensional Arrays
Write a C++ program which prompts the user to enter integer, float and character values into
the arrays defined in Task 9.2. Your program should have the following interface. Do this task
using ‘for’, ‘while’, and ‘do/while’ structures one by one.