2. Write a program to input a number x from the keyboard. If the number is larger than 0, find its square root. Otherwise, calculate x* x. Write the program by using selection statement. A sample of...


2. Write a program to input a number x from the keyboard. If the number is larger than 0,<br>find its square root. Otherwise, calculate x* x. Write the program by using selection<br>statement. A sample of the output showed as below.<br>Please enter a positive or negative number: -4<br>You have entered -4 which is smaller than 0<br>Therefore -4 x -4 = -8<br>Hint: Use include <math.h> to include sqrt function.<br>Example: root=sqrt(x);<br>

Extracted text: 2. Write a program to input a number x from the keyboard. If the number is larger than 0, find its square root. Otherwise, calculate x* x. Write the program by using selection statement. A sample of the output showed as below. Please enter a positive or negative number: -4 You have entered -4 which is smaller than 0 Therefore -4 x -4 = -8 Hint: Use include to include sqrt function. Example: root=sqrt(x);
3. A company sells five different products with prices shown in the following table<br>Retail Price Unit (RM)<br>15.50<br>Product Number<br>1<br>19.25<br>3<br>14.75<br>4<br>25.00<br>5<br>12.20<br>Write a program using switch-case statement that reads the product number and<br>number of units sold and display the amount to be paid.<br>Sample of the output shown as below<br>Please enter a product number: 5<br>Quantity : 4<br>Total amount to be paid: RM48.80<br>

Extracted text: 3. A company sells five different products with prices shown in the following table Retail Price Unit (RM) 15.50 Product Number 1 19.25 3 14.75 4 25.00 5 12.20 Write a program using switch-case statement that reads the product number and number of units sold and display the amount to be paid. Sample of the output shown as below Please enter a product number: 5 Quantity : 4 Total amount to be paid: RM48.80

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here