QBASIC homework help NEWBIE!
Posted: Mon Sep 03, 2012 4:41 pm
Hello,
I am taking a BASIC programming class in college using QBASIC and have been asked as an homework assignment to write a program that will input a number and print the number, the square of the number, and the cube of the number. Continue the operation until 999 is entered. My problem is that once I code the program and attempt to run it the operation stops and I get a bunch of zeros in the "Run" menu. Here is the code I am using:
*************************************************************
REM
REM *** This a program to find the square and cube of a number ***
REM *****************************************************************
REM
REM ***PROGRAM MAIN BODY***
CLS
GOSUB InitializeScreen
GOSUB InputData
GOSUB PrintData
RETURN
END
REM *************************************
REM *** Initialize Screen ***
REM *************************************
InitializeScreen:
CLS
RETURN
REM ***************************************
REM ***Print Data ***
REM ***************************************
InputData:
INPUT "Get number from user:$"; GivenNum
INPUT "DO until:$"; GivenNum999
INPUT "Square the number:$;"; GivenNum^ 2
INPUT "Cube the number:$;" GivenNum^3
CLS
END
LOOP
PrintData:
PRINT
PRINT "Get number from user:$"; GivenNum
PRINT "Square the number:$;"; GivenNum ^ 2
PRINT "Cube the number:$;"; GivenNum ^ 3
LOOP
END
The problem i'm having is that after the "PRINT "Square the number:$;"; GivenNum ^ 2" line I get an ", or end-of-statement error... can someone please help me fix this
Thank you!
I am taking a BASIC programming class in college using QBASIC and have been asked as an homework assignment to write a program that will input a number and print the number, the square of the number, and the cube of the number. Continue the operation until 999 is entered. My problem is that once I code the program and attempt to run it the operation stops and I get a bunch of zeros in the "Run" menu. Here is the code I am using:
*************************************************************
REM
REM *** This a program to find the square and cube of a number ***
REM *****************************************************************
REM
REM ***PROGRAM MAIN BODY***
CLS
GOSUB InitializeScreen
GOSUB InputData
GOSUB PrintData
RETURN
END
REM *************************************
REM *** Initialize Screen ***
REM *************************************
InitializeScreen:
CLS
RETURN
REM ***************************************
REM ***Print Data ***
REM ***************************************
InputData:
INPUT "Get number from user:$"; GivenNum
INPUT "DO until:$"; GivenNum999
INPUT "Square the number:$;"; GivenNum^ 2
INPUT "Cube the number:$;" GivenNum^3
CLS
END
LOOP
PrintData:
PRINT "Get number from user:$"; GivenNum
PRINT "Square the number:$;"; GivenNum ^ 2
PRINT "Cube the number:$;"; GivenNum ^ 3
LOOP
END
The problem i'm having is that after the "PRINT "Square the number:$;"; GivenNum ^ 2" line I get an ", or end-of-statement error... can someone please help me fix this
Thank you!