WAP to store a number. Now display cube of the number if its positive otherwise display its square qbasic
Answers
Answered by
6
Answer:
CLS
INPUT "ENTER A NUMBER";N
IF N>0
PRINT N^3
ELSE
PRINT N^2
ENDIF
END
Logic:-
- Accept a number
- check if it is greater than 0
- if yes, display the cube
- else, display the square
Answered by
3
Your program in QBASIC is as follows::
CLS
INPUT "Enter the number",n
IF n > 0 THEN
PRINT n * n
ELSE
PRINT n * n * n
END IF
END
Your program in PYTHON is as follows::
usin = int(input())
if usin > 0:
print usin * usin
else:
print usin * usin * usin
Your program in JAVA is as follows::
import java.util.Scanner;
public class Brainly {
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
int usin = sc.nextInt();
if (usin > 0) {
System.out.println(usin * usin);
}
else {
System.out.println(usin * usin * usin);
}
}
}
==> It takes input in n variable as of QBASIC program and in other programs , it is stored in usin variable.
==> It prints the square if positive integer, else prints cube.
Hope This Helps You..♪
Similar questions