tolfasn

part 2

Feb 11th, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.65 KB | None | 0 0
  1. /*
  2. 2) Write a program that inputs three integers and outputs the smallest, the largest, the sum
  3. and the average.
  4.  
  5. collect first input from user
  6. collect second input from user
  7. collect third input from user
  8. compare inputOne with inputTwo
  9.     if inputOne is less than inputTwo, rename inputOne to lowBall, and inputTwo to theMiddle
  10.     else rename inputTwo to lowBall and inputOne to theMiddle
  11. compare inputThree with lowBall
  12.     if inputThree is less than lowBall, rename inputThree as lowBall
  13.     else compare inputThree with theMiddle
  14.         if inputThree is less than theMiddle, rename inputThree as theMiddle, and rename remaining value as highBall
  15.         else rename inputThree as highBall
  16.    
  17. add lowBall, theMiddle, and highBall together
  18. rename the new integer value as "sum"
  19.  
  20. printf lowBall, highBall, and sum
  21. = not +
  22. */
  23.  
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #pragma warning(disable: 4996)
  28. //My compiler wont run with this tag for some reason
  29. //#include<string>
  30. #include<stdlib.h>
  31. #include<time.h>
  32.  
  33. /*
  34. ** Justin Sparks
  35. ** CIT 145
  36. ** Assignment 1: Part 2
  37. */
  38.  
  39. //Program to take three integer values, and compare them, to determine the greatest value.
  40. int main( void )
  41. {
  42.     //Placeholders for variable values
  43.     int inputOne, inputTwo, inputThree;
  44.     int lowBall, theMiddle, highBall, total, average;
  45.  
  46.     //Prompts the user for first value, and stores it as inputOne.
  47.     printf ("Please enter your first integer: ");
  48.     scanf("%d", &inputOne);
  49.  
  50.     //Prompts the user for second value, and stores it as inputTwo.
  51.     printf ("Please enter your second integer: ");
  52.     scanf ("%d", &inputTwo);
  53.  
  54.     //Prompts the user for third value, and stores it as inputThree.
  55.     printf ("Please enter your second integer: ");
  56.     scanf ("%d", &inputThree);
  57.  
  58.     //Conditional statement to determine greater value, of the values provided by the user.
  59.     //Sets variable based on value.
  60.     if (inputOne < inputTwo){
  61.         inputOne = lowBall;
  62.         inputTwo = theMiddle;
  63.     }
  64.     //alternative branch, if first value is greater.
  65.     else {
  66.         inputTwo = lowBall;
  67.         inputOne = theMiddle;
  68.     }
  69.  
  70.     //Conditional statement to determine greater value, of the values provided by the user.
  71.     //Sets variable based on value.
  72.     if (inputThree < lowBall){
  73.         lowBall = theMiddle;
  74.         inputThree = lowBall;
  75.  
  76.          if (inputThree < theMiddle){
  77.         inputThree = theMiddle;
  78.        
  79.         }
  80.     }
  81.     //alternative branch, if first value is greater.
  82.  
  83.  
  84.     //Prints the final result to the user.
  85.     printf("\n%d is the greater number!\n", larger);
  86.  
  87.     system("pause");
  88.    
  89.     return 0;
  90. }
Add Comment
Please, Sign In to add comment