Professional Documents
Culture Documents
List/Table
1 Haseeb
2 Eshal
3 Musa
4 Maryam
5 Aysham
6 Rida
7 Sara
position dimensions
1D:
//Declaration
DECLARE Names[1:7] : STRING
//Input programmer defined values, and output the values
Names[1]=”haseeb”
Names[2]=”eshal”
Names[3]=”musa”
Names[4]=”fatima”
Names[5]=”ali”
//output all
FOR count= 1 TO 5
PRINT Names[count]
NEXT
//take 5000 names from the user
DECLARE Names[1:5000] : STRING
FOR count = 1 TO 5000
PRINT “please enter the names”
INPUT Names[count]
NEXT
FOR count= 2000 TO 4000
PRINT Names[count]
NEXT
//EXAMPLE 3
//set up an array to store, 500 numbers, reject the numbers that are in between 200 to 300.
DECALRE Numbers[1:500] : INTEGER
FOR count= 1 TO 500
PRINT “please enter numbers”
INPUT Numbers[count]
IF Numbers[count]>200 AND Numbers[count]<300 THEN
//MISTAKE
IF Numbers>200 AND Numbers<300 //you have to use index
PRINT “Invalid Number entered, please re-enter”
INPUT Numbers[count]
NEXT
// totaling in loop
total=total+num
//totaling in array
total=total+Num[count]
//highest
IF num>highest THEN highest=num
IF Num[count]>highest THEN highest=Num[count]
//ALWAYS HAVE TO WORK ON THE INDEX WHILE MANIPULATING ARRAY
//Set up an array Nums[] to store 300 numbers, make sure the numbers entered are positive, if positive
then find the average, highest and lowest of the numbers and output as well.