0% found this document useful (0 votes)
37 views

Start: If Array (I) Small

The document contains a flowchart, algorithm, and C++ program to find the smallest number and its occurrence count from an array of 10 integers. The flowchart shows initializing variables, reading each array element, comparing it to the smallest, and updating smallest and count as needed. The algorithm describes the same steps in pseudocode. The C++ program implements these steps by initializing variables, taking user input to populate the array, finding the smallest number and its count, and printing the results.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Start: If Array (I) Small

The document contains a flowchart, algorithm, and C++ program to find the smallest number and its occurrence count from an array of 10 integers. The flowchart shows initializing variables, reading each array element, comparing it to the smallest, and updating smallest and count as needed. The algorithm describes the same steps in pseudocode. The C++ program implements these steps by initializing variables, taking user input to populate the array, finding the smallest number and its count, and printing the results.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Question1:

Flowchart:

Start

Small=1000; counter=0;i=0

Initialize the Array

Read Array[i]

ii+1

Yes

If Array[i]<small

small = Array[i]

No
OccOcc+1

Yes
i<10
No

Print smallest
int, occ

END

Algorithm:
Start
Initialize the local integers
Small = 1000;
Initialize the Array
For i from 1 to 10 do
Read Array(i)
If(smallest<tab(i))
smallest<-tab(i)
occ = occ + 1 // Occurrence Counter
endif
end for
Print(smallest Integer, occ)
END

Program C++:
#include<iostream.h>
void main( void)
{

int myArray[10];
int small=10000;
int counter=0;
cout<<"Enter ten(10) numbers to be check for small value
and occurence count\n";

for(int i=0;i<10;i++) //Loop which will take 10 numbers from user.


{
cout<<"\nEnter No"<<i+1<<" : ";
cin>>myArray[i];
if(myArray[i] < small) //compare if number stored in array is < 10000
{
small = myArray[i];

}
}

for(int iLoop=0; iLoop<10; iLoop++)

// loop which will count the occurrence of smallest number

{
if (myArray[iLoop] == small)
counter+=1;
}
cout<<"\n"""<<small<<" ""is the smallest number repeated
("<<counter<<") times";

}
Print screen:

You might also like