Computer Programming Learning Part-06||Week-06||C++ program to find the largest number out of ten integers using array.

in Steem4Professionals2 months ago

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.

Programming Learning Part 06.png
Design By Canva


Step01:

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.

IMG20240622124736.jpg

IMG20240622124654.jpg


Step02:

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.

c-1.png

c2.png

c3.png


Step03:

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()
{


Step03:

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};


Step04:

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;


Step05:

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++)
{


Step06:

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];
}


Step07:

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;
}

c5.png


Step08:

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.

c6.png

output big.png

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.

Blue line.png

Link to my previous post:

Part-01

Part-02

Part-03

Part-04

Part-05

Blue line.png

Steemit.com.png

image.png

Sort:  
Loading...

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(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.

Upvoted. Thank You for sending some of your rewards to @null. It will make Steem stronger.

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 61297.02
ETH 2687.45
USDT 1.00
SBD 2.59