Computer Programming Learning Part-06||Week-06||C++ program to find the largest number out of ten integers using array.
Steemian Friends,
Today, I am going to write my Computer Programming Learning Part-06. Today, I will find a number greater than ten using an array in a C++ program. Hopefully, my program writing can be easily understood and learned by everyone.
Design By Canva
First I write the C++ program on a white paper. Then I will output my written program to the computer through Code Blocks software. I can easily type on the computer because I wrote the program on paper first. Below is a picture of the program written on white paper.
Then I turn on my laptop and open the Code Blocks software. Then I started writing the program on paper in the compiler part of the code. The whole process is shown in the image below.
Then I first declare the header file and main function of the C++ program. At the beginning of the C++ program, these two parts must be written first. Below I have declared the header file and main function.
#include<stdio.h>
int main()
{
Then I declared ten numbers of integer type. I have shown how to declare arrays in my previous programming learning part. Now, I have declared ten numbers of integer type through an array. I will use the previous learning parts while doing projects from now on. I have given ten numbers through the array declared below. From here we will find the larger number. The following line will store ten integer-type numbers in memory. Below, I have declared the array.
int a[10] = {3,100,50,200,10,20,2,5,7,1};
Now I will compare the number in the zero array with the numbers in the next array one by one. I first assumed that the number in the zero array was large. I put this large number in a variable called i. Below I have written it in the form of a program.
int max = a[0], I;
Then I will use the for loop of my previous learning part. A for loop will compare the first number in the array with the numbers in the next array one by one and find the larger number. Below, I have shown using a for loop.
for (i=1;i<10; i++)
{
Then I will compare each array with the next array through the if function. Here at the end of the ten-number comparator, the number that is found to be larger will be kept in an array named max. Below is the program shown.
if (a[i] > max)
max = a[i];
}
Then I will write a program to see the output of the program. Where my ten digits will show the larger number obtained. Below I have written the program line.
printf ("Max value is : %d\n", max);
return 0;
}
Then I write the whole program and click on the run option to see the output. Then, I see output 200 on a black page. 200 was the largest of my ten numbers. If, I want I can edit the program to find bigger numbers with more numbers.
When writing my program and outputting it, it didn't show any error. I was very happy to see the output. Gradually, I am moving towards doing bigger projects with my C++ programs.
Link to my previous post:
Thank you, friend!
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmd7of2TpLGqvckkrReWahnkxMWH6eMg5upXesfsujDCnW/image.png)
![image.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmWDnFh7Kcgj2gdPc5RgG9Cezc4Bapq8sQQJvrkxR8rx5z/image.png)
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
please click it!
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)
The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.
This is my Twitter share link :
https://twitter.com/mahadih83660186/status/1804416946223616301?t=LICNTIVvhaUnsCxOBW-KiQ&s=19
Upvoted. Thank You for sending some of your rewards to @null. It will make Steem stronger.