View Single Post
Old 03-06-2008, 07:39 PM   #436 (permalink)
Cool Joe
The Black Waltz
 
Join Date: Apr 2008
Location: The Shed
Posts: 1,511
Default Re: Post ur C/C++ Programs Here

This is my program written in C. it does unit conversions.
Code:
#include<stdio.h>
#include<conio.h>
main()
{
int opt,con;
float in,cm,ina,cma,ft,m,ma,fta,m1,y,m1a,ya,km,mile,mile1,km1,nmile,metre;
float nmile1,metre1,usgal,usl,usgal1,usl1,ukl,ukgal,ukl1,ukgal1,gram,oz;
float oz1,gram1,kg,lbs,lbs1,kg1,kw,hp,kw1,hp1,df,dc,df1,dc1;
clrscr();

printf("------------------------------Converter by Shishir------------------------------\n");
printf("\n1.Conversions\n");
printf("\n2.About Converter\n");
printf("\n3.Exit\n");
printf("\nEnter your choice:");
scanf("%d",&opt);

if(opt==1)
{
clrscr();
printf("\n1.inch to centimetre  2.centimetre to inch\n");
printf("\n3.foot to metre       4.metre to foot\n");
printf("\n5.yard to metre       6.metre to yard\n");
printf("\n7.mile to kilometre   8.kilometre to mile\n");
printf("\n9.n mile to metre     10.metre to n mile\n");
printf("\n11.US gal to litre    12.litre to US gal\n");
printf("\n13.UK gal to litre    14.litre to UK gal\n");
printf("\n15.Oz to gram         16.gram to Oz\n");
printf("\n17.pound to Kg        18.Kg to pound\n");
printf("\n19.hp to kw           20.kw to hp\n");
printf("\nEnter your unit of conversion:");
scanf("%d",&con);

if(con==1)
{
clrscr();
printf("How many inches? :");
scanf("%f",&in);
cm=in*2.54;
printf("\n\nConversion is %f CM",cm);
}

else if(con==2)
{
clrscr();
printf("How many centimtres? :");
scanf("%f",&cma);
ina=cma/2.54;
printf("\n\nConversion is %f IN",ina);
}

else if(con==3)
{
clrscr();
printf("How many feet? :");
scanf("%f",&ft);
m=ft/3.280839895;
printf("\n\nConversion is %f M",m);
}
else if(con==4)
{
clrscr();
printf("How many metres? :");
scanf("%f",&ma);
fta=ma*3.280839895;
printf("\n\nConversion is %f FT",fta);
}

else if(con==5)
{
clrscr();
printf("How many yards? :");
scanf("%f",&y);
m1=y/1.093613298;
printf("\n\nConversion is %f M",m1);
}

else if(con==6)
{
clrscr();
printf("How many metres? :");
scanf("%f",&m1a);
ya=m1a*1.093613298;
printf("\n\nConversion is %f Y",ya);
}

else if(con==7)
{
clrscr();
printf("How many miles? :");
scanf("%f",&mile);
km=mile*1.609344;
printf("\n\nConversion is %f KM",km);
}

else if(con==8)
{
clrscr();
printf("How many KMs? :");
scanf("%f",&km1);
mile1=km1/1.609344;
printf("\n\nConversion is %f miles",mile1);
}

else if(con==9)
{
clrscr();
printf("How many nautical miles? :");
scanf("%f",&nmile);
metre=nmile*1852;
printf("\n\nConversion is %f M",metre);
}
else if(con==10)
{
clrscr();
printf("How many metres? :");
scanf("%f",&metre1);
nmile1=metre1/1852;
printf("\n\nConversion is %f N MILES",nmile1);
}
else if(con==11)
{
clrscr();
printf("How many US gallons? :");
scanf("%f",&usgal);
usl=usgal*3.785412;
printf("\n\nConversion is %f L",usl);
}

else if(con==12)
{
clrscr();
printf("How many litres? :");
scanf("%f",&usl1);
usgal1=usl1/3.785412;
printf("\n\nConversion is %f US GAL",usgal1);
}

else if(con==13)
{
clrscr();
printf("How many UK gallons? :");
scanf("%f",&ukgal);
ukl=ukgal*4.54609;
printf("\n\nConversion is %f L",ukl);
}

else if(con==14)
{
clrscr();
printf("How many litres? :");
scanf("%f",&ukl1);
ukgal1=ukl1/4.54609;
printf("\n\nConversion is %f UK GAL",ukgal1);
}

else if(con==15)
{
clrscr();
printf("How many oz? :");
scanf("%f",&oz);
gram=oz*28.34952;
printf("\n\nConversion is %f G",gram);
}

else if(con==16)
{
clrscr();
printf("How many grams? :");
scanf("%f",&gram1);
oz1=gram1/28.34952;
printf("\n\nConversion is %f OZ",oz1);
}

else if(con==17)
{
clrscr();
printf("How many lbs? :");
scanf("%f",&lbs);
kg=lbs/2.204622476;
printf("\n\nConversion is %f KG",kg);
}

else if(con==18)
{
clrscr();
printf("How many kgs? :");
scanf("%f",&kg1);
lbs1=kg1*2.204622476;
printf("\n\nConversion is %f LBS",lbs1);
}

else if(con==19)
{
clrscr();
printf("How much hp? :");
scanf("%f",&hp);
kw=hp/1.341021859;
printf("\n\nConversion is %f KWs",kw);
}

else if(con==20)
{
clrscr();
printf("How many KWs? :");
scanf("%f",&kw1);
hp1=kw1*1.341021859;
printf("\n\nConversion is %f HP",hp1);
}

}

else if(opt==2)
{
clrscr();
printf("\nThis is a freeware by Shishir Upadhya.");
}

else if(opt==3)
{
printf("\nPress any key to exit...");
}

getch();
}
plz tell me wat u think abt it.

__________________
#krow @ irc.freenode.net

Last edited by mehulved; 08-06-2008 at 09:50 PM.
Cool Joe is offline