# Programming Help

Okay, I really need some help here…
BASIC programming, btw.

The situation:

``````FOR X = 1 TO 3
IF SMALLLOOP = 1 THEN FULL(X) = A(X) ELSE FULL(I need a fucking formula here) = A(X)
NEXT X
``````

SMALLLOOP is 1 the first time this loop is run, then it just increases by 1 each time it runs.
I’m attempting to store 3 numbers in A(X) each time, hence the 1 to 3… and I need a formula that will allow me to store 3 numbers each time, not skipping any room on the Array (So it’s all nice and neat). And I have no clue. It’d be good to have it based off of the variable “SMALLLOOP” since that’s how i input my numbers… anyone help?

Edit: I need this solution VERY soon =\

Does it have to be BASIC? I could do that with C or C#, if you’re using Visual Studio.

Well, I figured out a better way to do it, but sure… lemme see the C++ version. I’m attempting to learn that too

Edit: this was for a class assignment, but I wasn’t sure until I looked at it a different way.

#include(stdio.h)
#include(stdlib.h)

int number_store(int A, B, C){
int array[3];
array[0] = A;
array[1] = B;
array[2] = C;
return (array[]);
}

int main(void){
int A, B, C;
scanf("%f %f %f", &A, &B, &C);
number_store(A, B, C);
}

You can then add printf and friendly messages to the user, or whatever else you wish to these programs. The way I put it, the main program will catch what the user inputs and then throw them to the program that will store them, but it may be adjusted to change the way the numbers are caught. Also, I put stdlib up there so you can use a system(“PAUSE”) at the end of the main program.

By the way, I used () after include because if I use the > and < the board will think they’re html tags and hide what’s in them, but you know that you should use them instead of ().

Is it possible to do in BASIC?
I understand what you’re doing in C++, but wouldn’t that be pretty hard to do in BASIC?

Oh… and here’s the whole program for those that care:

``````
CLS
TEAMS = 2
OPEN "BQ3.DAT" FOR INPUT AS #1
DIM G(15)
FOR BIGLOOP = 1 TO TEAMS
INPUT #1, NB, TEAM\$
PRINT TAB(40 - LEN(TEAM\$) \ 2); TEAM\$
PRINT : PRINT
PRINT "   BOWLER            G-1   G-2   G-3";
PRINT "      TOTAL    AVG     HDCP     HG"
PRINT
FOR SMALLLOOP = 1 TO NB
INPUT #1, BN\$(SMALLLOOP)
FOR X = 1 TO 3
INPUT #1, A(X)
T = T + A(X)
NEXT X
AVG = FIX(T / 3)
HDCP = FIX((200 - AVG) * .75)
IF HDCP < 0 THEN HDCP = 0
PRINT USING "#.)"; SMALLLOOP;
PRINT TAB(4); BN\$(SMALLLOOP);
PRINT USING "###"; TAB(22); A(1); SPC(3); A(2); SPC(3); A(3); SPC(8); T; SPC(4); AVG; SPC(6); HDCP;
1                       FOR X = 1 TO 2
IF A(X) < A(X + 1) THEN SWAP A(X), A(X + 1): GOTO 1
NEXT X
PRINT USING "###"; SPC(4); A(1);
G(SMALLLOOP) = A(1)
FOR X = 1 TO 3
T(X) = T(X) + A(X)
NEXT X
T = 0
PRINT
NEXT SMALLLOOP
0               FOR X = 1 TO NB - 1
IF G(X) < G(X + 1) THEN SWAP G(X), G(X + 1): SWAP BN\$(X), BN\$(X + 1): GOTO 0
NEXT X
PRINT
PRINT "Highest game bowled by "; BN\$(1); G(1)
PRINT : PRINT
SLEEP
NEXT BIGLOOP

'----I need help with this portion, the same problem...----

CLOSE
OPEN "BQ3.DAT" FOR INPUT AS #1
INPUT #1, A, T\$
FOR X = 1 TO A
INPUT #1, BN\$(X)
FOR Y = 1 TO 3
INPUT #1, A(X)
NEXT Y

NEXT X

'----This is like... the end =o----
END

``````

And BQ3.DAT contains this:

``````
5, Team #1
John King, 148,137,167,Joe Smith,201,135,192,Mary Lommer,180,170,156,Johnny Rotten,200,234,299,Jim Belushi,150,145,300
2, Team #2
Sally Ride,123,109,230,Last One,100,76,145

``````

It’s because things are harder in BASIC that most people I know switch to the C family.

I have only a slight grasp at BASIC. I took a C++ course the last two months, just as a preparatory bridge for C# which I’ll be taking for, like, 4 years. I’ll also take a look at J++. But no BASIC, unless I want to take a brief look into Visual Basic 6.

1. This is C, not C++… be careful if you want to use it as part of your solution.
2. number_store should return an integer type but returns an array of integer type instead. Also, number_store has no value left of any assignment operator; it should be somearray = number_store(A, B, C). Better yet, it should be void number_store (*A, *B, *C) with no return value, and the calling function number_store (&A, &B, &C).
3. Where exactly are you trying to store the numbers? A(X)? And where are the numbers coming from?

Cless, the numbers are coming from the ‘scanf’, and stored in the array called ‘array’. I give in, though, when you say I should use

(insert a declared array here) = number_store(A,B,C);

And about the way things are being returned. Would putting the ] and [ (in the correct order) right after number_store work?

My compiler says C++… If this is C, then could you please show me how it would go in C++?

#include < iostream.h > //I don’t use the namespace std, bite me
// no space after the < or before the >

//insert number_store code

void main()
{
int A, B, C;
cin >> A >> B >> C;
number_store(A, B, C);
}

I think that’s right. I haven’t done anything in C++ for a couple months, so I’m a little (read: very) rusty.

Thanks

Er, the last question was direct as Steve I wasn’t very clear on that; sorry

As long as array[3] is local to the function “number_store”, it still be deleted the moment the “number_store” function is terminated. You could make array[3] global or pass along the entire array itself by declaring something in main. For example,

void main () {
int A, B, C;
int array[3];
scanf("%f %f %f", &A, &B, &C);
number_store(array, &A, &B, &C);
}

void number_store(int localarray[], int *A, int *B, int *C)
{
localarray[0] = A;
localarray[1] = B;
localarray[2] = C;
}

This is kinda complicated, though, and you don’t really need to make another function to just stuff three numbers in an array

The main difference between C++ and C is actually in that C++ makes use of OOP… but since this program doesn’t get that complicated, there’s a secondary difference in that C++ makes use of the concept of data streams instead of something like printf and scanf.

#include<iostream>

void main() {
int a, b, c;
int array[3];
cin >> a;
cin >> b;
cin >> c;
array[0] = a;
array[1] = b;
array[2] = c;
}

And your compiler may be MS Visual C++ or whatever, but C and C++ can both be compiled by it. The major difference is in the way your program and in the header files that you use. You can even use an odd mix of C and C++ syntax if you include header files from both…

C, Java, C++, C#, etc are to BASIC as Scheme, ML, CaML, etc. are to C, Java, C++, C#, etc.

The proprietary technologies being developed by Microsoft, Sun, etc would be a whole lot simpler in a functional language framework. Functional style programming is so much easier to understand. Instead they are falling back to their old procedural ways, and throwing objects in and calling it object oriented. Object oriented is a new way to organize procedural code. Procedural style coding makes sense for certain things, especially where performance is important and the domain is well understood anyway. But for many common tasks, a functional framework would work out so much better…