This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:psechris:portfolio:cprogproject8 [2013/02/15 21:23] – psechris | user:psechris:portfolio:cprogproject8 [2013/03/13 14:02] (current) – psechris | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | A project for CSCS 1320 by Paul Sechrist during the Spring 2013. | ||
+ | =====Objectives===== | ||
+ | State the purpose of this project. What is the point of this project? What do we hope to accomplish by undertaking it? | ||
+ | |||
+ | |||
+ | =====Code===== | ||
+ | |||
+ | <code c 1> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | #define NUM_SCORES 5 | ||
+ | #define SCORE0 87 | ||
+ | #define SCORE1 92 | ||
+ | #define SCORE2 97 | ||
+ | #define SCORE3 83 | ||
+ | #define SCORE4 79 | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | unsigned char *scores; | ||
+ | float average; | ||
+ | |||
+ | scores = (unsigned char *) malloc (sizeof(unsigned char) * NUM_SCORES); | ||
+ | *(scores+0) = SCORE0; | ||
+ | *(scores+1) = SCORE1; | ||
+ | *(scores+2) = SCORE2; | ||
+ | *(scores+3) = SCORE3; | ||
+ | *(scores+4) = SCORE4; | ||
+ | |||
+ | average = ((float)(SCORE0+SCORE1+SCORE2+SCORE3+SCORE4)/ | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | |||
+ | return(0); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | =====Execution===== | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | Your scores are, 87, 92, 97, 83, 79 | ||
+ | Your average is, 87.599998 | ||
+ | lab46: | ||
+ | </ | ||
+ | <cli> | ||
+ | lab46: | ||
+ | gettinginput1.c: | ||
+ | / | ||
+ | gettinginput1.c: | ||
+ | / | ||
+ | gettinginput1.c: | ||
+ | / | ||
+ | gettinginput1.c: | ||
+ | / | ||
+ | gettinginput1.c: | ||
+ | / | ||
+ | gettinginput1.c: | ||
+ | / | ||
+ | gettinginput1.c: | ||
+ | / | ||
+ | gettinginput1.c: | ||
+ | / | ||
+ | </ | ||
+ | <cli> | ||
+ | lab46: | ||
+ | Enter an integer: 1 | ||
+ | Enter another integer: 2 | ||
+ | Enter a short int: 3 | ||
+ | Enter a char: Enter a float value: 4 | ||
+ | Your ints are: 1 and 2 | ||
+ | Your short int is: 3 | ||
+ | Your char is: ' | ||
+ | ' | ||
+ | Your float (trimmed at 2 decimal places) is: 4.00 | ||
+ | lab46: | ||
+ | </ |