Advertisement
tolfasn

part1

Feb 11th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.44 KB | None | 0 0
  1. /*
  2. 1) Write a program that inputs two integers and outputs the larger of the two.
  3.  
  4. collect first input from user
  5. collect second input from user
  6. compare the two outputs:
  7.     if inputOne is greater than inputTwo, printf inputOne
  8.     else printf inputTwo
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #pragma warning(disable: 4996)
  14. //My compiler wont run with this tag for some reason
  15. //#include<string>
  16. #include<stdlib.h>
  17. #include<time.h>
  18.  
  19. /*
  20. ** Justin Sparks
  21. ** CIT 145
  22. ** Assignment 1: Part 1
  23. */
  24.  
  25. //Program to take two integer values, and compare them, to determine the greatest value.
  26. int main( void )
  27. {
  28.     //Placeholders for variable values
  29.     int inputOne;
  30.     int inputTwo;
  31.     int larger;
  32.  
  33.     //Prompts the user for first value, and stores it as inputOne.
  34.     printf ("Please enter your first integer: ");
  35.     scanf("%d", &inputOne);
  36.  
  37.     //Prompts the user for second value, and stores it as inputTwo.
  38.     printf ("Please enter your second integer: ");
  39.     scanf ("%d", &inputTwo);
  40.  
  41.     //Conditional statement to determine greater value, of the two provided by the user.
  42.     //Sets final value to second input.
  43.     if (inputTwo > inputOne){
  44.         larger = inputTwo;
  45.     }
  46.     //alternative branch, if first value is greater.
  47.     else {
  48.         larger = inputOne;
  49.     }
  50.  
  51.     //Prints the final result to the user.
  52.     printf("\n%d is the greater number!\n", larger);
  53.  
  54.     system("pause");
  55.    
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement