User:Jbet011

Hello, this is a program i made in enggen131 -- /*this program converts a given amount of either kilograms or pounds to the other measurement*/


 * 1) define _CRT_SECURE_NO_DEPRECATE


 * 1) include 


 * 1) include 

int main(void)

{

//variable initialization

int conversionOp;

double value, output;

char from[15];

printf("Are you converting from 'kilograms' or 'pounds'? ");

scanf("%s", &from);

printf("\nHow many %s do you have? ", from);

scanf("%lf", &value);

if ((from[0]=='k')|| (from[0]=='K')){

conversionOp=1;

}else if ((from[0]=='p')||(from[0]=='P')){

conversionOp=2;

}

else printf("\nNot a valid input, please restart\n");

if (conversionOp==1){

output=value*2.2046226218;

printf("%.3f kilograms is equal to %.3f pounds \n ", value, output);

}

else if (conversionOp==2) {

output=value/2.2046226218;

printf("%.3f pounds is equal to %.3f kilograms \n ", value, output);

}

return 0;

} ---

As mentioned at the top of the program, it is used to convert either pounds to kilograms or kilograms to pounds. An example of the output produced by the code can be seen here:

"Are you converting from 'kilograms' or 'pounds'? kilograms

How many kilograms do you have? 10.66 10.660 kilograms is equal to 23.501 pounds Press any key to continue..."

this is in the command prompt window, it is a handy program to have around =)