Posted by: Sourav | December 6, 2013

Finding Duplicates in an array in qbasic


10 DIM names(4) AS STRING

20 DIM k AS INTEGER

21 DIM names2(4) AS STRING

22 k = 0

 

 

30 FOR i = 1 TO 4

31 INPUT “Enter Names”, names2(i)

 

60 FOR j = 1 TO i – 1

 

70 IF UCASE$(names2(i)) = UCASE$(names2(j)) THEN

80 PRINT “Duplicates not allowed”

81 k = 1

 

85 EXIT FOR

86 END IF

 

 

87 NEXT j

 

92 IF k = 0 THEN

93 names(i) = names2(i)

 

 

95 ELSE

 

 

 

 

 

 

101 k = 0

102 i = i – 1

 

105 END IF

 

 

 

300 NEXT i

400 FOR i = 1 TO 4

500 PRINT names(i)

600 NEXT i

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: