{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Homework5-2

# Homework5-2 - Homework#5 Program HW5_2 Written by Justin...

This preview shows pages 1–2. Sign up to view the full content.

Homework #5 /* * Program: HW5_2 * Written by: Justin Waters * inputs: 4 letters representing resistor color codes * Outputs: Resistor ohm value * Description: User enters 4 letters representing color codes of a resistor and the program determines the ohms for the given color code and prints the results * */ #include <stdio.h> #include <math.h> #include <ctype.h> //declaration of functions: void color_letters(char colorCode[]); //gets users letter code inputs long ohm_convert( char colorCode[], int r_value ); //converts colors to numbers void description(void); //tells user about the program int main (void) { long r_value = 0; char colorCode[4]; description(); //calls ddescription function color_letters(colorCode); //calls function to collect user inputs color codes r_value = ohm_convert(colorCode, r_value); //converts colors to numbers and returns final value //prints color code and calculated resistor value printf("\n\nThe resistor with color code %c %c %c %c has a value of %d Ohms.\n", toupper(colorCode[0]), toupper(colorCode[1]), toupper(colorCode[2]), toupper(colorCode[3]), r_value); return 0; } void description(void) //description function

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

Homework5-2 - Homework#5 Program HW5_2 Written by Justin...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online