QBASIC – Calculate the sum of cubes

The program below calculates the sum of cubes of two user input numbers.

' Program to find sum of cubes of two user input numbers
CLS
INPUT "Enter the first number: "; a
INPUT "Enter the second number: "; b
sum = a ^ 3 + b ^ 3
PRINT "Sum of cubes of ";a;" and ";b;" is: ";sum
END

Explanation:

To calculate the sum of cubes of two user input numbers. We are using the exponentiation operator (^) to calculate the cubes of the numbers i.e., a ^ 3 and b ^ 3 to calculate the cubes of a and b respectively.

Leave a Comment

Your email address will not be published. Required fields are marked *