(C Programming Language)
DECISIONS – ENGINEERING NOTATION
Write a C Language Program that will prompt for and read in a voltage value (in volts). Your program will then determine if the proper representation (i.e., value between 1.00 and 999.99) of the voltage would be Gigavolts, Megavolts, kilovolts, volts, millivolts, microvolts, or nanovolts. Include the appropriate abbreviation for the units with your numeric answer. If you are not familiar with engineering notation, research the topic online. Correct abbreviations for the voltage levels are :
Gigavolts GV millivolts mV
Megavolts MV Volts V microvolts mV
Kilovolts kV nanovolts nV
Demonstrate your working program for the Instructor. Include a commented listing with your report.
Note:- All the explaination is given in the comments per line.
#include <stdio.h>
void main()
{
float volt; //Declaring the variable
printf("Enter Value in Volt Between(1.0 to 999.99)=");
scanf("%f",&volt); //Scan the value
if(volt>999.99 || volt<1) //Checking if the number is greater
than 999.99 and less than 1
{
printf("Enter a valid number!!!");
}
else
{
printf("Volts to Gigavolt (GV) =%.15f",(volt*0.000000001));
//Converting Volt To Gigavolt by multiplying volt*0.000000001
printf("\nVolts to MegaVolt (MV) =%.9f",(volt*0.000001));
//Converting Volt To MegaVolt by multiplying volt*0.000001
printf("\nVolts to KiloVolt (kV) =%.9f",(volt*0.001)); //Converting
Volt To KiloVolt by multiplying volt*0.001
printf("\nVolt (V) = %.9f",volt); //Printing Volt
printf("\nVolts to milliVolts (mV) =%.9f",(volt*1000));
//Converting Volt To milliVolt by multiplying volt*1000
printf("\nVolts to microVolts (µV) =%.9f",(volt*1000000));
//Converting Volt To microVolt by multiplying volt*1000000
printf("\nVolts to nanoVolts (nV) =%.9f",(volt*1000000000));
//Converting Volt To nanoVolt by multiplying volt*1000000000
}
}
OUTPUT:-
Enter Value in Volt Between(1.0 to 999.99)=20
Volts to Gigavolt (GV) =0.000000020000000
Volts to MegaVolt (MV) =0.000020000
Volts to KiloVolt (kV) =0.020000000
Volt (V) = 20.000000000
Volts to milliVolts (mV) =20000.000000000
Volts to microVolts (µV) =20000000.000000000
Volts to nanoVolts (nV) =20000000000.000000000
Get Answers For Free
Most questions answered within 1 hours.