How Apps Find Data in C++ | Search an Array and Find the Position of a Number

Опубликовано: 07 Июнь 2026
на канале: Real Programming Skool (RPS)
16
1

In this lesson, we write a C++ program that fills an array with random numbers from 1 to 100, then asks the user which number she/he wants to check.

After that, the program searches the array and tells us whether the number exists or not. If the number is found, it shows the position of the number in the array and the order of the number in the list. If the number is not found, it prints that the number does not exist in the array.

For example, if the user inputs:
5

The output can be:
The Array Elements: 16 70 59 23 27

Then the user enters:
2

The Number You Are Looking For Is: 2
The Number Is Not Found :-(

In another example, if the user inputs:
5

The output can be:
The Array Elements: 64 43 74 23 37

Then the user enters:
23

The Number You Are Looking For Is: 23
The Number Found At Position: 3
The Number Order Is: 4

In this video, you will learn:
• How to fill an array with random numbers in C++
• How to ask the user for a number to search for
• How to search an array step by step
• How to find the position of a number in the array
• How to know the order of the number in the array
• How to handle the case when the number is not found
• How to build a useful search function for arrays
• How this logic is used in apps, websites, and search features

This lesson is a very important beginner-friendly introduction to arrays, searching, loops, conditions, and functions in C++.

It also shows how re-usability and extendability work in programming, because we keep the random-fill function and add a new function for finding the number inside the array.

If you are learning C++ problem solving step by step, this lesson will help you understand arrays, indexing, searching, and how real applications search for stored data.

This lesson 33 of Course 4: Problem Solving for Programmers Using C++ (Part 2) – Beginner Track.

▶ 🖥️ Start Here – Programming Roadmap & How to Learn Programming Step by Step:
   • Start Here – Programming Roadmap & How to ...  

▶ Join the Real Programming Skool community on Telegram:
http://t.me/RPSDiscussionChannel

#cplusplus #cpp #arrays #searching #programming #codingforbeginners #problemsolving #functions #loops #realprogrammingskool