Skip to main content

UNIT CONVERTER PROGRAM IN C.

THIS PROGRAM IS WRITTEN IN C /* Program to convert length to different units*/ #include int main(void) { float length, converted, measure; char inUnits, outUnits; printf("Enter the value of length to be converted: "); scanf("%f", &measure); printf("Enter the unit of value entered (I, F, Y, or M): "); scanf("%c", &inUnits); printf("Enter the unit to convert value to (c, m, or k): "); scanf("%c", &outUnits); switch(inUnits){ case 'I': converted = measure * 2.54001; printf("The length you entered in inches is equal to %f centimeters", converted); break; case 'Y': converted = measure * 0.9144402; printf("The length you entered in yards is equal to %f meters", converted); break; case 'M': converted = measure * 1.60935; printf("The length you entered in miles is equal to %f kilometers", converted); break; case 'F': switch(outUnits){ case 'c': converted = measure * 30.4801; printf("The length you entered in feet is equal to %f centimeters", converted); break; case 'm': converted = measure * 0.304801; printf("The length you entered in feet is equal to %fmeters", converted); break; default: printf("Incorrect unit entered. Please enter a valid unit."); break;} break; default: printf("Incorrect unit entered. Please enter a valid unit."); break;} return 0; } Faq

Comments

Popular posts from this blog

PROGRAMMING WITH C 7.12      (Card Shuffling and Dealing) Modify the program in Fig. 7.24 so that the card-dealing function deals a five-card poker hand. Then write the following additional functions: a) Determine whether the hand contains a pair. b) Determine whether the hand contains two pairs. c) Determine whether the hand contains three of a kind (e.g., three jacks). d) Determine whether the hand contains four of a kind (e.g., four aces). e) Determine whether the hand contains a flush (i.e., all five cards of the same suit). f) Determine whether the hand contains a straight (i.e., five cards of consecutive face values) ANSWER 7.12 #include<stdio.h> #include<stdlib.h> #include<time.h> //main functions void shuffle( int wDeck[][ 13 ] ); void deal( const int wDeck[][ 13 ], const char *wface[], const char *wSuit[], char *wfSuit[], char *wfFace[] ); //operation functions void pair( const char *...
Hei guys ! Watch out for more on c plus plus

Coding..........