Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 1) Write a program that inputs two integers and outputs the larger of the two.
- collect first input from user
- collect second input from user
- compare the two outputs:
- if inputOne is greater than inputTwo, printf inputOne
- else printf inputTwo
- */
- #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 1
- */
- //Program to take two integer values, and compare them, to determine the greatest value.
- int main( void )
- {
- //Placeholders for variable values
- int inputOne;
- int inputTwo;
- int larger;
- //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);
- //Conditional statement to determine greater value, of the two provided by the user.
- //Sets final value to second input.
- if (inputTwo > inputOne){
- larger = inputTwo;
- }
- //alternative branch, if first value is greater.
- else {
- larger = inputOne;
- }
- //Prints the final result to the user.
- printf("\n%d is the greater number!\n", larger);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement