Posted by: Sourav | December 6, 2013

Finding the highest and lowest element in an array in qbasic


‘finding the highest and lowest element of an array

CLS

 

FOR i = 1 TO 5

INPUT “”, number(i)

 

NEXT i

 

PRINT

PRINT

 

 

FOR j = 1 TO 5

PRINT number(j)

NEXT j

x = number(1)

y = number(1)

FOR k = 2 TO 5

IF x > number(k) THEN

x = number(k)

 

 

ELSEIF y < number(k) THEN

y = number(k)

END IF

 

NEXT k

 

 

PRINT “highest”; y

PRINT “lowest”; x

END

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: