1.
Declare an Array:
2. Input the Size of the Array:
o Ask the user to enter the number of elements in the array.
o Store this value in a variable size.
3. Take Input for Array Elements:
o Use a loop to take input from the user for each element of the array. For each
index i (starting from 0 to size - 1), store the value entered by the user in
arr[i].
4. Print the Array in Reverse:
o Use another loop to print the elements of the array starting from the last index
(size - 1) down to the first index (0).
o Print each element as you traverse the array in reverse order.
5. End of the Program:
o Once the array is printed in reverse, the program ends.
In summary:
1. Input the number of elements.
2. Input the elements into an array.
3. Print the elements from the array in reverse order
Algorithm Steps:
1. Initialize Variables:
o Declare variables size, num, and count.
o Set count to 0 initially to keep track of the occurrences.
2. Input Array Size:
o Print a message prompting the user to enter the number of elements in the
array.
o Read the input value and store it in the variable size.
3. Declare the Array:
o Create an integer array arr with a size of size to hold the elements entered by
the user.
4. Input Array Elements:
o Print a message asking the user to enter size number of elements.
o Use a loop that runs from 0 to size - 1:
For each iteration, read an integer from the user and store it in arr[i].
5. Input the Number to Count:
o Print a message prompting the user to enter the number whose occurrences
need to be counted.
o Read the input value and store it in the variable num.
6. Count Occurrences:
o Use a loop that runs from 0 to size - 1:
For each element in the array, check if arr[i] is equal to num.
If they are equal, increment the count variable by 1.
7. Output the Result:
o Print the number num along with the value of count, indicating how many
times num occurs in the array.
8. End of the Program:
o Return 0 to indicate successful completion of the program.
Initialize variables and input the size of the array.
Input the elements of the array.
Input the number to count.
Count how many times that number occurs in the array.
Print the result.