Assignment 3

4. Ask the user for 10 numbers and output the number in ascending and descending order.

CPE102L
1Q1819
Code:
start

	int size=10, temp, temp2
	int gtech[size], tempgtech[size]

	print “Enter 10 numbers:”
	for (int a=0; a<size; a++)
		input gtech[a]
		tempgtech[a]=gtech[a]
	end for
	for (int a=0; a<size; a++)
		for (int b=a; b<size; b++)
			if (gtech[a]>gtech[b])
				temp=gtech[a]
				gtech[a]=gtech[b]
				gtech[b]=temp
			end if
			if (tempgtech[a]<tempgtech[b])
				temp2=tempgtech[a]
				tempgtech[a]= tempgtech[b]
				tempgtech[b]=temp2
			end if
		end for
	end for

	print “the numbers in ascending order; “
for (int a=0; a<size; a++)
		print gtech[a], “   “
	end for

print endl, “the numbers in descending order; “
for (int a=0; a<size; a++)
		print tempgtech[a], “   “
	end for

end