0% found this document useful (0 votes)
5 views2 pages

Activity Array1

The document provides a set of programming tasks that require writing C++ programs utilizing arrays to achieve specific output displays. Each task includes instructions for creating arrays, manipulating data, and printing results, covering various concepts such as initialization, user input, loops, and condition checking. The final output must match the specified format for each display, emphasizing the importance of arrays in the solutions.

Uploaded by

elrodjosh350
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Activity Array1

The document provides a set of programming tasks that require writing C++ programs utilizing arrays to achieve specific output displays. Each task includes instructions for creating arrays, manipulating data, and printing results, covering various concepts such as initialization, user input, loops, and condition checking. The final output must match the specified format for each display, emphasizing the importance of arrays in the solutions.

Uploaded by

elrodjosh350
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Activity : Array

Name _______________________________________ Course & Section ______________ Score ______

Materials:
Paper: 8.5” x 13”
Submission: April 21, 2025

Instruction:

For each of the output displays shown below, write a complete C++ program that, when compiled and
executed, will produce that exact output. Your code should utilize arrays to store and manipulate the data
being displayed. Ensure your program includes the necessary <iostream> header for output operations.
Provide the complete .cpp source code for each output. Remember to emphasize the use of arrays in their
solutions. (3 points each)

Output Display 1:
Element at index 0: 10
Element at index 1: 20
Element at index 2: 30

Instruction for Output Display 1:


"Write a C++ program that declares an integer array of size 3, initializes its elements with the values 10, 20,
and 30 respectively, and then prints each element along with its index as shown in the output."

Output Display 2:
Greeting: Hello

Instruction for Output Display 2:


"Write a C++ program that declares a character array capable of holding the string "Hello" (including the null
terminator). Initialize the array with the characters of the string and then print the entire string to the
console."

Output Display 3:
Student Scores:
Score 1: 85
Score 2: 92
Score 3: 78
Score 4: 95
Score 5: 88

Instruction for Output Display 3:


"Write a C++ program that creates an integer array containing the scores 85, 92, 78, 95, and 88. Use a loop
to iterate through the array and print each score along with a corresponding student number (starting from
1)."

Output Display 4:
Enter the ages of 3 people:
Age of person 1: [User Input Here]
Age of person 2: [User Input Here]
Age of person 3: [User Input Here]

Entered ages are:


Person 1: [Same as User Input 1]
Person 2: [Same as User Input 2]
Person 3: [Same as User Input 3]
Instruction for Output Display 4:
"Write a C++ program that prompts the user to enter the ages of three people. Store these ages in an
integer array. After receiving the input, display the entered ages, associating each age with a person
number (starting from 1)."

Output Display 5:
The sum of the array elements is: 50

Instruction for Output Display 5:


"Write a C++ program that initializes an integer array with the values 5, 10, 15, and 20. Calculate the sum of
all the elements in the array using a loop and then print the calculated sum to the console."

Output Display 6:
The maximum element in the array is: 89

Instruction for Output Display 6:


"Write a C++ program that creates an integer array containing the values 12, 45, 2, 89, and 30. Find the
largest element within the array using a loop and then print the maximum value."

Output Display 7:
Original array: 1 2 3 4 5
Reversed array: 5 4 3 2 1

Instruction for Output Display 7:


"Write a C++ program that initializes an integer array with the sequence 1, 2, 3, 4, and 5. First, print the
original array. Then, reverse the order of the elements within the array using a loop and appropriate logic
(you may use a second loop to print the reversed array)."

Output Display 8:
33 is present in the array.

Instruction for Output Display 8:


"Write a C++ program that creates an integer array containing the values 15, 28, 33, 41, and 50. Write code
to check if the number 33 exists within the array. Print a message indicating whether the number was found
or not."

Output Display 9:
Elements in the destination array: 100 200 300

Instruction for Output Display 9:


"Write a C++ program that initializes an integer array named source with the values 100, 200, and 300.
Declare another integer array named destination of the same size. Write a loop to copy each element from
the source array to the destination array. Finally, print the elements of the destination array."

Output Display 10:


The number 5 appears 3 times in the array.

Instruction for Output Display 10:


"Write a C++ program that initializes an integer array with the values 5, 10, 5, 15, 5, and 20. Write code to
count the number of times the value 5 appears in the array. Print the count to the console."

You might also like