Q basic WAP to store weight in grams . Now covert and display it into kg.
Answers
Answered by
2
The given code is written in QBASIC.
CLS
INPUT "Enter weight in grams: "; G
KG = G / 1000
PRINT "Weight in kg ="; KG
END
- Line 1: Clears the screen.
- Line 2: Accept the weight in grams.
- Line 3: Divide the weight by 1000 to get the weight in kg.
- Line 4: Display the weight in kg.
- Line 5: End of program.
See the attachment for output.
Attachments:
Answered by
2
You can use the following program::
CLS
INPUT "Enter weight in grams : ", grams
PRINT "Your answer in KGs : " + grams / 1000
END
Output::
Sample input = 10000
Sample output = Your answer in KGs : 10
Logic::
==> Grams are stored in variable named gram.
==> It takes input and outputs it in KGs.
Hope This Helps You..♪
Similar questions