This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:lburzyns:portfolio:project1 [2011/11/07 03:55] – [References] lburzyns | user:lburzyns:portfolio:project1 [2011/11/07 06:11] (current) – [Reflection] lburzyns | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | A project for CPROG by Lauren Burzynski during the Fall 2011. | ||
+ | |||
+ | This project was begun on November 1, 2011 and was finished on November 6, 2011. | ||
+ | |||
+ | =====Objectives===== | ||
+ | |||
+ | The purpose of the project is to master arithmetic operators, learn how they are used properly within a program, and to write a code with output based on user input. | ||
+ | =====Prerequisites===== | ||
+ | In order to successfully accomplish/ | ||
+ | |||
+ | * ability to log into lab46 | ||
+ | * ability to edit text files | ||
+ | * ability to compile C source code | ||
+ | * knowledge of basic arithmetic operators in C programming | ||
+ | * abilitiy to create a basic program in C programming | ||
+ | * knowledge of basic arithmetic | ||
+ | |||
+ | =====Background===== | ||
+ | The purpose of this project is to explore arithmetic expressions, | ||
+ | |||
+ | In my Opus part 2, experiment 1 was a good jumping off point for this project (see link below): | ||
+ | http:// | ||
+ | |||
+ | I took what I learned from that experiment, which basically entailed whether or not I would receive a negative number when I subtracted 20 from 10. The answer turned out to be yes, I did receive a negative number. | ||
+ | Generally, what is going to happen is I will write a code that allows the user to input 2 different values for 2 different integers to be added, subtracted, multiplied, and divided. | ||
+ | <code c> | ||
+ | 10 + 10 = 20 | ||
+ | </ | ||
+ | The results vary given the input, as well as the operator called on at the time. After this result is given, then the program will prompt the user for more values to use in the next arithmetic expression, and will continue on through all four operators. | ||
+ | =====Scope===== | ||
+ | This project will be exploring the nature of arithmetic operators available in C programming language. How to write a program with arithmetic expressions that allows the user to input numbers as variables instead of assigning values to the variables at the beginning of the code. | ||
+ | |||
+ | A program will be written that will display all of the arithmetic operators being used properly. | ||
+ | |||
+ | The arithmetic operators being used include: | ||
+ | |||
+ | * Addition (+) | ||
+ | * Subtraction (-) | ||
+ | * Multiplication (*) | ||
+ | * Division (/) | ||
+ | | ||
+ | =====Attributes===== | ||
+ | |||
+ | * variables: A variable will be assigned for each input number and the values will be determined by user input | ||
+ | * arithmetic operators: Arithmetic operators will be used within the program and clearly defined | ||
+ | |||
+ | =====Procedure===== | ||
+ | |||
+ | To accomplish this project, I first had to to some research on how to neatly and properly write a whole program where the user was inputing the values for the integers being added, subtracted, multiplied, and divided. | ||
+ | =====Code===== | ||
+ | <code c> | ||
+ | #include < | ||
+ | |||
+ | int main () | ||
+ | { | ||
+ | int firstNum, secondNum, delta = 0; | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | delta = firstNum + secondNum; | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | scanf(" | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | delta = firstNum - secondNum; | ||
+ | printf(" | ||
+ | | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | delta = firstNum * secondNum; | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | scanf(" | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | delta = firstNum / secondNum; | ||
+ | printf(" | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | =====Execution===== | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | Enter 1st number to be added(x): 5 | ||
+ | Enter 2nd number to be added(y): 5 | ||
+ | x + y = 10 | ||
+ | Enter 1st number to be subtracted(x): | ||
+ | Enter 2nd number to be subtracted(y): | ||
+ | x - y = 0 | ||
+ | Enter 1st number to be multiplied(x): | ||
+ | Enter 2nd number to be multiplied(y): | ||
+ | x * y = 25 | ||
+ | Enter 1st number to be divided(x): 5 | ||
+ | Enter 2nd number to be divided(y): 5 | ||
+ | x / y = 1 | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | =====Reflection===== | ||
+ | |||
+ | After I successfully completed this project, I felt accomplished and proud. | ||
+ | =====References===== | ||
+ | In performing this project, the following resources were referenced: | ||
+ | |||
+ | * http:// | ||
+ | This website helped me properly write and execute a program based on arithmetic operators. | ||
+ | * http:// | ||
+ | This website was helpful because it posts a short program that shows the basics behind arithmetic operators. | ||
+ | * http:// | ||
+ | This website was useful because it lists in the " | ||
+ | * http:// | ||
+ | This website was useful in the early stages. |