How to Fill an Array with Random Numbers and Find the Smallest Number in C++

Опубликовано: 08 Июнь 2026
на канале: Real Programming Skool (RPS)
8
0

In this lesson, we write a C++ program that fills array elements with random numbers from 1 to 100, then finds and prints the smallest number in the array.

The user first enters how many elements he wants. After that, the program fills the array automatically with random values, displays the array elements, and returns the smallest number inside the array.

For example, if the user inputs:
5

The output can be:
Array Elements are: 77 88 38 30 99

The Smallest Number In The Array Is: 30

In this video, you will learn:
• How to fill an array with random numbers in C++
• How to ask the user for the number of array elements
• How to generate random numbers from 1 to 100
• How to store random values inside array elements
• How to display the array using DisplayArray()
• How to build a function to find the smallest number in the array
• How to compare array elements step by step
• How to reuse previous functions in a practical C++ problem
• How to think like a programmer by extending an existing solution

This lesson is a very important beginner-friendly introduction to arrays, random number generation, and finding the minimum value in C++.

It also shows how reusability and extendability work in programming, because we keep the previous functions and only play with the logic of the last function from the previous lesson for finding the smallest number, and we change its name as well.

If you are learning C++ problem solving step by step, this lesson will help you understand arrays, loops, functions, comparisons, and how to build larger solutions from smaller reusable parts.

This lesson 24 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 #randomnumbers #programming #codingforbeginners #problemsolving #functions #loops #realprogrammingskool