Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Kind of easy ?
#11
BANANA..lol..

ok so another words i could creat the For Loops to do everything with the 3 arrays and it will work.. Like i say I am a newbie..BANANA....LOL..

Im kinda seeing what you are asking..Ill keep at it.
Reply
#12
Hey, FMJ

I think your problem might be that you don't "get" arrays. Consider the following code:
Code:
CLS
tableSize = 10
FOR i = 1 TO tableSize
  FOR j = 1 TO tableSize
    PRINT USING " ###"; i * j;
  NEXT j
  PRINT
NEXT i

Works great...prints the mult table...however, you can't *do* anything with the data...it is simply dumped to screen then lost. If you modify it as follows...

Code:
DIM table(100) AS INTEGER
counter = 0
CLS
tableSize = 10
FOR i = 1 TO tableSize
  FOR j = 1 TO tableSize
    counter = counter + 1
    table(counter) = i * j
  NEXT j
NEXT i

FOR i = 1 TO 100
  PRINT USING " ###"; table(i);
  IF i MOD 10 = 0 THEN PRINT
NEXT i

At first glance, you accomplish the same thing...however, there's a HUGE difference. In the second example, you have stored the whole table, rather than just simply dumping the contents to screen. Now...from here it's a simple exercise to add x to each array element...

Code:
DIM table(100) AS INTEGER
counter = 0
CLS
tableSize = 10
FOR i = 1 TO tableSize
  FOR j = 1 TO tableSize
    counter = counter + 1
    table(counter) = i * j
  NEXT j
NEXT i

FOR i = 1 TO 100
  PRINT USING " ###"; table(i);
  IF i MOD 10 = 0 THEN PRINT
NEXT i

PRINT
PRINT

x = 3

FOR i = 1 TO 100
  table(i) = table(i) + x
NEXT i

FOR i = 1 TO 100
  PRINT USING " ###"; table(i);
  IF i MOD 10 = 0 THEN PRINT
NEXT i

If you are confused by the MOD statement...ask.

Hope this helps.

Mango
Reply
#13
yes sir.. What exactly is mod. Sorry guys for being so stupid. BANANA.. Sad
Reply
#14
Mango's code is too genius for me to understand...but MOD is an operator that stands for modulus. It returns the remainder of two numbers, when divided. For instance, 5 MOD 3 returns 2, and 6 MOD 5 returns 1.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#15
so its actually just subtracting the two numbers. Hmm ok.. I will work on this probably later today. I have to chunks of math to get done and then ill be working on the programs. Thanks for the help guys. Ill let you know if i have any problems.
Reply
#16
ok with the last bit of code i keep getting a subscript out of range at the line

table(counter)= i*j
Reply
#17
I have code somewhat working but not getting much for numbers.. Now i cant remember for the life of me how i made the code save to notepad through file...
Reply
#18
Ok - to get the code in windows make sure you are saving as TEXT ( there is an option is the save dialouge box).

Then just take Notepad, and open the .bas file. easy! (you may need to select "all files" in the box under the filename input.) the format is saved in pure text, so it is easy to port it through to windows.
Reply
#19
K thanks.. I forgot the program at work so ill try and do what i had done and post it tonight..
Reply
#20
Quote:CLS
DIM table(12) AS INTEGER
counter = 0
CLS
tablesize = 12
PRINT " x ! 1 2 3 4 5 6 7 8 9 10 11 12"
PRINT "____+_______________________________________________"
FOR i = 1 TO tablesize
PRINT USING "### _!"; i;
FOR j = 1 TO tablesize
counter = counter + 1
PRINT USING "####"; i * j;
NEXT j
PRINT
NEXT i
PRINT
'PRINT CHR$(12)
FOR i = 1 TO tablesize
PRINT USING "###"; i;
IF i MOD 12 = 0 THEN PRINT
NEXT i
PRINT
PRINT
x = 3

'PRINT CHR$(12)

FOR i = 1 TO 12
table(i) = table(i) + x
NEXT i

FOR i = 1 TO 12
PRINT USING "###"; table(i);
IF i MOD 12 = 0 THEN PRINT
NEXT i

Ok this is what i have so far.. What i get is the mult. table and then below it i get the numbers 1-12 and the bottom line of code gives me all 3's..

uhhh. Sorry just fed up with school, teacher screws me on a english paper, had a math test, still have two more programs after this to have wrote by saturday cause my dumb butt keeps getting stuck on labs, then test all week next week.. Im burning out and losing hope. Sad
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)