4. Write a program in QBASIC to find the value of the given expressions after taking a suitable value of a and b from the console:
(i) a2 + b2
(ii) a+b/ab
Answers
Answered by
14
Following are the code for the above question:
Explanation:
Program:
INPUT "Enter the value for a variable";a 'Take the value for "a" variable.
INPUT "Enter the value for b variable";b 'Take the value for "b" variable.
PRINT (a*a)+(b*b) 'calculate and print the value for first option.
PRINT (a+b)/(a*b) 'calculate and print the value for the second option.
Output:
- If the user gives the input as 4 and 5 then the output is 41 for the first expression and 0.45 for the second expression.
- If the user gives the input as 5 and 6, then the output is 61 for the first expression and 0.36666666666666664 for the second expression.
Code Explanation:
- The above code is in QBasic language, in which the first line and the second line of the program render a message to the user, take the input from the user and store it into a and b variable.
- Then the two print statement takes the print the value for the question statement.
Learn More:
- QBasic : https://brainly.in/question/4169343
Answered by
2
the expression (a+b)2 can be written in Qbasic as follows
Similar questions
Math,
5 months ago
Hindi,
11 months ago
History,
11 months ago
Geography,
1 year ago
Social Sciences,
1 year ago