MicroLink Information Technology College
Department of Computer Science
CSSE-133 Programming Fundamentals I
Worksheet 6 (Array/Pointer/String)
1. Write and test a program that replaces all the negative numbers in an array of integers with
their absolute values.
2. Write and test a program that returns the minimum value stored in an array.
3. Write and test a program that returned the index of the minimum value stored in an array.
4. Write and test a C++ program that attempts to remove an item from an array:
5. Write and test a program that adds element-wise 2 one-dimensional int arrays of the same
size. For example, if the two given arrays are
22 33 44 55
and
7 4 1 -2
then the third array would be assigned
29 37 45 53
6. Write a C++ program that accepts any word from keyboard to display the word’s reverse.
Example: Input : Ethiopia
Output: aipoihtE
7. Write a program that reads a sequence of words from the console until the word stop is
entered, and then prints the reversed sequence (without the final stop).
Example: Input: Gallia est omnis divisa in partes tres stop
Output: tres partes in divisa omnis est Gallia
8. Write a program that reads a sequence of positive integers (until the user enters a non-
positive number) and then prints a histogram of all the integer value between the smallest and
the largest integer the user has entered, i.e., for each such value the number of occurrences of
that value in the sequence entered by the user.
Example: Input: 5 10 12 7 10 10 5 11 7 12 10 0
Output:
MicroLink Information Technology College
Department of Computer Science
CSSE-133 Programming Fundamentals I
Worksheet 6 (Array/Pointer/String)
1. Write and test a program that replaces all the negative numbers in an array of integers with
their absolute values.
2. Write and test a program that returns the minimum value stored in an array.
3. Write and test a program that returned the index of the minimum value stored in an array.
4. Write and test a C++ program that attempts to remove an item from an array:
5. Write and test a program that adds element-wise 2 one-dimensional int arrays of the same
size. For example, if the two given arrays are
22 33 44 55
and
7 4 1 -2
then the third array would be assigned
29 37 45 53
6. Write a C++ program that accepts any word from keyboard to display the word’s reverse.
Example: Input : Ethiopia
Output: aipoihtE
7. Write a program that reads a sequence of words from the console until the word stop is
entered, and then prints the reversed sequence (without the final stop).
Example: Input: Gallia est omnis divisa in partes tres stop
Output: tres partes in divisa omnis est Gallia
8. Write a program that reads a sequence of positive integers (until the user enters a non-
positive number) and then prints a histogram of all the integer value between the smallest and
the largest integer the user has entered, i.e., for each such value the number of occurrences of
that value in the sequence entered by the user.
Example: Input: 5 10 12 7 10 10 5 11 7 12 10 0
Output: