Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 2) Write a program that inputs three integers and outputs the smallest, the largest, the sum
- and the average.
- collect first input from user
- collect second input from user
- collect third input from user
- compare inputOne with inputTwo
- if inputOne is less than inputTwo, rename inputOne to lowBall, and inputTwo to theMiddle
- else rename inputTwo to lowBall and inputOne to theMiddle
- compare inputThree with lowBall
- if inputThree is less than lowBall, rename inputThree as lowBall
- else compare inputThree with theMiddle
- if inputThree is less than theMiddle, rename inputThree as theMiddle, and rename remaining value as highBall
- else rename inputThree as highBall
- add lowBall, theMiddle, and highBall together
- rename the new integer value as "sum"
- printf lowBall, highBall, and sum
- = not +
- */
- #include <stdio.h>
- #include <stdlib.h>
- #pragma warning(disable: 4996)
- //My compiler wont run with this tag for some reason
- //#include<string>
- #include<stdlib.h>
- #include<time.h>
- /*
- ** Justin Sparks
- ** CIT 145
- ** Assignment 1: Part 2
- */
- //Program to take three integer values, and compare them, to determine the greatest value.
- int main( void )
- {
- //Placeholders for variable values
- int inputOne, inputTwo, inputThree;
- int lowBall, theMiddle, highBall, total, average;
- //Prompts the user for first value, and stores it as inputOne.
- printf ("Please enter your first integer: ");
- scanf("%d", &inputOne);
- //Prompts the user for second value, and stores it as inputTwo.
- printf ("Please enter your second integer: ");
- scanf ("%d", &inputTwo);
- //Prompts the user for third value, and stores it as inputThree.
- printf ("Please enter your second integer: ");
- scanf ("%d", &inputThree);
- //Conditional statement to determine greater value, of the values provided by the user.
- //Sets variable based on value.
- if (inputOne < inputTwo){
- inputOne = lowBall;
- inputTwo = theMiddle;
- }
- //alternative branch, if first value is greater.
- else {
- inputTwo = lowBall;
- inputOne = theMiddle;
- }
- //Conditional statement to determine greater value, of the values provided by the user.
- //Sets variable based on value.
- if (inputThree < lowBall){
- lowBall = theMiddle;
- inputThree = lowBall;
- if (inputThree < theMiddle){
- inputThree = theMiddle;
- }
- }
- //alternative branch, if first value is greater.
- //Prints the final result to the user.
- printf("\n%d is the greater number!\n", larger);
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment