0% found this document useful (0 votes)
38 views

Write The Code To Execute and Verify The Results of The Following Situations

The document provides code snippets to write programs that: 1) Convert temperatures between Celsius and Fahrenheit. 2) Convert between inches and centimeters. 3) Convert between miles and kilometers. 4) Calculate the surface area and volume of a cube given the length of one side.

Uploaded by

harsh verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Write The Code To Execute and Verify The Results of The Following Situations

The document provides code snippets to write programs that: 1) Convert temperatures between Celsius and Fahrenheit. 2) Convert between inches and centimeters. 3) Convert between miles and kilometers. 4) Calculate the surface area and volume of a cube given the length of one side.

Uploaded by

harsh verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

 Write the code to execute and verify the results of the following situations:

A. Ask the user for a temperature value in celcius (C) and convert it to Fahrenheit (F) value.
HINT : Formula is F = C * 9 / 5 + 32
Syntax

Sub temperature()
Dim c As Single, f As Single
c = InputBox("enter value in celcius")
f = c * 9 / 5 + 32
Debug.Print "tempeature in farenhite:" & f
End Sub

Output :

B. Ask the user to input a valuein inches and convert it to cms

HINT: Formula Is 1 inch = 2.54cms

Syntax:

Sub length()
Dim inch As Single, cms As Single
inch = InputBox("enter value in inches")
cms = inch * 2.54
Debug.Print "lenght in cms is:" & cms
End Sub

Output:

C. Ask the user to input value in miles and convert in kilometers.

HINT: 1 Mile = 1.609344 kms


Syntax :

Sub tempreature()
Dim mile As Single, kms As Single
mile = InputBox("enter value in miles")
kms = mile * 1.609344
Debug.Print "lenght in kms is:" & kms
End Sub
Output :

D. Ask the user to input the value of the sides of a cube and display the total surface area and volume of the
cube.
HINT:
1. Total surface area of cube : 6 * I^2
2. Volume of cube: I * I * I
Syntax:

Sub tempreature()
Dim i As Single
i = InputBox("enter side of cube")
area = 6 * i * i
volume = i * i * i
Debug.Print "area of cuboid is:" & area
Debug.Print "volume of cuboid is:" & volume
End Sub
Output:

You might also like