PROGRAM TO FIND SQUARE, CUBE, SQUARE ROOT AND CUBE ROOT OF GIVEN NUMBER
7. Display square of an input number.
REM PROGRAM TO DISPLAY SQUARE OF AN INPUT NUMBER
CLS
INPUT “ENTER ANY NUMBER”; N
S = N ^ 2
PRINT “SQUARE OF NUMBER ”; S
END
USING SUB PROCEDURE
DECLARE SUB SQUARE (N)
CLS
INPUT “ENTER ANY NUMBER”; N
CALL SQUARE(N)
END
SUB SQUARE (N)
S = N ^ 2
PRINT “SQUARE OF NUMBER “; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SQUARE (N)
CLS
INPUT “ENTER ANY NUMBER”; N
S = SQUARE(N)
PRINT “SQUARE OF NUMBER “; S
END
FUNCTION SQUARE (N)
SQ= N ^ 2
SQUARE = SQ
END FUNCTION
8. Display cube of an input number.
REM PROGRAM TO DISPLAY CUBE OF AN INPUT NUMBER
CLS
INPUT “ENTER ANY NUMBER”; N
C = N ^ 3
PRINT “CUBE OF NUMBER ”; C
END
USING SUB PROCEDURE
DECLARE SUB CUBE (N)
CLS
INPUT “ENTER ANY NUMBER”; N
CALL CUBE(N)
END
SUB CUBE (N)
C = N ^ 3
PRINT “CUBE OF NUMBER “; C
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CUBE (N)
CLS
INPUT “ENTER ANY NUMBER”; N
C = CUBE(N)
PRINT “CUBE OF NUMBER “; C
END
FUNCTION CUBE (N)
CB = N ^ 3
CUBE = CB
END FUNCTION
9. Display square root of an input number.
REM PROGRAM TO DISPLAY SQUARE ROOT OF AN INPUT NUMBER
CLS
INPUT “ENTER ANY NUMBER”; N
S = N ^ (1 / 2)
PRINT “SQUARE ROOT OF NUMBER ”; S
END
USING SUB PROCEDURE
DECLARE SUB SQROOT (N)
CLS
INPUT “ENTER ANY NUMBER”; N
CALL SQROOT(N)
END
SUB SQROOT (N)
S = N ^ (1 / 2)
PRINT “SQUARE ROOT OF NUMBER “; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SQROOT (N)
CLS
INPUT “ENTER ANY NUMBER”; N
S = SQROOT(N)
PRINT “SQUARE ROOT OF NUMBER “; S
END
FUNCTION SQROOT (N)
SQ= N ^ (1 / 2)
SQROOT = SQ
END FUNCTION
10. Display cube root of an input number.
REM PROGRAM TO DISPLAY CUBE ROOT OF AN INPUT NUMBER
CLS
INPUT “ENTER ANY NUMBER”; N
C = N ^ (1 / 3)
PRINT “CUBE ROOT OF NUMBER ”; C
END
USING SUB PROCEDURE
DECLARE SUB CBROOT (N)
CLS
INPUT “ENTER ANY NUMBER”; N
CALL CBROOT(N)
END
SUB CBROOT (N)
C = N ^ (1 / 3)
PRINT “CUBE ROOT OF NUMBER “; C
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CBROOT (N)
CLS
INPUT “ENTER ANY NUMBER”; N
C = CBROOT(N)
PRINT “CUBE ROOT OF NUMBER “; C
END
FUNCTION CBROOT (N)
CB= N ^ (1 / 3)
CBROOT = CB
END FUNCTION
11. Display sum of square of any two input numbers.
REM PROGRAM TO DISPLAY SUM OF SQUARE OF ANY TWO INPUT NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
S = A ^ 2 + B ^ 2
PRINT “SUM OF SQUARE OF TWO NUMBERS ”; S
END
USING SUB PROCEDURE
DECLARE SUB SQUARE (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
CALL SQUARE(A, B)
END
SUB SQUARE (A, B)
S = A ^ 2 + B ^ 2
PRINT “SUM OF SQUARE OF TWO NUMBERS “; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SQUARE (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
S = SQUARE(A, B)
PRINT “SUM OF SQUARE OF TWO NUMBERS “; S
END
FUNCTION SQUARE (N)
SQ= A ^ 2 + B ^ 2
SQUARE = SQ
END FUNCTION
12. Display sum of cube of any two input numbers.
REM PROGRAM TO DISPLAY SUM OF CUBE OF ANY TWO INPUT NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
C = A ^ 3 + B ^ 3
PRINT “SUM OF CUBE OF TWO NUMBERS ”; C
END
USING SUB PROCEDURE
DECLARE SUB CUBE (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
CALL CUBE (A, B)
END
SUB CUBE (A, B)
C = A ^ 3 + B ^ 3
PRINT “SUM OF CUBE OF TWO NUMBERS “; C
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CUBE (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
C = CUBE (A, B)
PRINT “SUM OF CUBE OF TWO NUMBERS “; C
END
FUNCTION CUBE (N)
CB= A ^ 3 + B ^ 3
CUBE = CB
END FUNCTION
13. Display sum of square of any three input numbers.
REM PROGRAM TO DISPLAY SUM OF SQUARE OF ANY THREE INPUT NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
S = A ^ 2 + B ^ 2 + C ^ 2
PRINT “SUM OF SQUARE OF THREE NUMBERS ”; S
END
USING SUB PROCEDURE
DECLARE SUB SQUARE (A, B, C)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
CALL SQUARE(A, B, C)
END
SUB SQUARE (A, B, C)
S = A ^ 2 + B ^ 2 + C ^ 2
PRINT “SUM OF SQUARE OF THREE NUMBERS “; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SQUARE (A, B, C)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
S = SQUARE(A, B, C)
PRINT “SUM OF SQUARE OF THREE NUMBERS “; S
END
FUNCTION SQUARE (N)
SQ= A ^ 2 + B ^ 2 + C ^ 2
SQUARE = SQ
END FUNCTION
14. Display sum of cube of any three input numbers.
REM PROGRAM TO DISPLAY SUM OF CUBE OF ANY THREE INPUT NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
S = A ^ 3 + B ^ 3 + C ^ 3
PRINT “SUM OF CUBE OF THREE NUMBERS ”; S
END
USING SUB PROCEDURE
DECLARE SUB CUBE (A, B, C)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
CALL CUBE (A, B, C)
END
SUB CUBE (A, B, C)
C = A ^ 3 + B ^ 3 + C ^ 3
PRINT “SUM OF CUBE OF THREE NUMBERS “; C
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CUBE (A, B, C)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
C = CUBE (A, B, C)
PRINT “SUM OF CUBE OF THREE NUMBERS “; C
END
FUNCTION CUBE (N)
CB= A ^ 3 + B ^ 3 + C ^ 3
CUBE = CB
END FUNCTION
Comments
Nice post, It's really very simple and easy. Keep sharing.
i have completed my computer assignment of qbasic programming by analyzing this programming
DIM A(20)
FOR I=1 TO 20
INPUT A(I)
S=S+A(I)
NEXT I
PRINT S
END
You see, Wesley was in the army-and shortly after leaving-he unveiled hidden, "MIND CONTROL" secrets that the government and others used to obtain everything they want.
THESE are the exact same tactics lots of famous people (especially those who "come out of nothing") and elite business people used to become rich and famous.
You probably know that you use less than 10% of your brain.
That's mostly because most of your brain's power is UNTAPPED.
Maybe this conversation has even taken place IN YOUR own head... as it did in my good friend Wesley Virgin's head 7 years ago, while riding an unregistered, beat-up bucket of a car without a license and $3 in his bank account.
"I'm very frustrated with living paycheck to paycheck! When will I become successful?"
You've been a part of those those questions, isn't it right?
Your very own success story is going to happen. You just need to take a leap of faith in YOURSELF.
Watch Wesley Virgin's Video Now!