-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathifelse.c
46 lines (35 loc) · 1.13 KB
/
ifelse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Purpose: Read two integers and determine the relationships between them.
#include <stdio.h>
// function main begins program execution
int main(void)
{
int num1; // first number to be read from user
int num2; // second number to be read from user
// Prompt the user to enter two integers
printf("Enter two integers, and I will tell you\n");
printf("the relationships they satisfy: ");
// Read two integers from the user
scanf("%d%d", &num1, &num2);
// Check the relationships between the two numbers using if statements
if (num1 != num2)
{
printf("%d is not equal to %d\n", num1, num2);
} // end if
if (num1 < num2)
{
printf("%d is less than %d\n", num1, num2);
} // end if
if (num1 > num2)
{
printf("%d is greater than %d\n", num1, num2);
} // end if
if (num1 <= num2)
{
printf("%d is less than or equal to %d\n", num1, num2);
} // end if
if (num1 >= num2)
{
printf("%d is greater than or equal to %d\n", num1, num2);
} // end if
return 0; // indicate that program ended successfully
} // end function main