How To Make it Limited to 100?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream.h>
#include<iomanip.h>
void main()
{
	int i,j,smalltest,temp;
	int Array[8];
	cout<<"Masukkan nilai!!!"<<endl;
	for (int a=0; a<=7; a++)
	{
		cout<<"Nilai "<<a + 1<<" : ";
		cin>>Array[a];
	}
	cout<<"Data sebelum di urutkan:\n\n";
	for(int k=0;k<=7;k++)
	{
		cout<<setw(3)<<Array[k];
	}
	for(i=0;i<=7;i++)
	{
		smalltest=i;
		for(j=i+1;j<=7;j++)
		{
			if(Array[smalltest]>Array[j])//Ascending
			{
				smalltest=j;
			}
		}
		temp=Array[i]; 
		Array[i]=Array[smalltest];
		Array[smalltest]=temp;
	}
	cout<<"\n\nData setelah di urutkan:\n\n";
	for(int l=0;l<=7;l++)
	{
		cout<<setw(3)<<Array[l];
	}
	cout<<"\n\n";
}


HOW TO MAKE IT LIMITED LIKE "WHEN YOU FILL THE NUMBER,IT MUST NOT LARGER THAN 100,& WHEN YOU PUT LARGER,IT WILL END" HOW CAN I MAKE ? TQ
I am unable to understand your language in code. I think you are trying to sort a list of 8 elements.

What you want in it? Ask question clearly.
Last edited on
int Array[5];

void TestNumber()
{
for (int a=0; a<=5; a++)
{
int x=0;
cout << "Number: ";
cin >> x;
if ((x>0) && (x<=100))
{Array[a]=x;}
else
{cout << "x<>100 Exit now";}
}
cout << endl;
for (int a=0; a<=5; a++)
{
cout <<Array[a] << " " ;
}
}
Topic archived. No new replies allowed.