Skip to content

Instantly share code, notes, and snippets.

@anonur
Last active April 4, 2019 19:13
Show Gist options
  • Select an option

  • Save anonur/39f647acfa7bc24a805a456d3ddad333 to your computer and use it in GitHub Desktop.

Select an option

Save anonur/39f647acfa7bc24a805a456d3ddad333 to your computer and use it in GitHub Desktop.
Compare two numbers with if
#include<stdio.h>
int main(void)
{
int num1;
int num2;
printf("Enter two integers, and I will tell you\n");
printf("the relationships they satisfy: ");
scanf("%d %d", &num1,&num2);
if(num1 == num2) {
printf("%d is equal to %d\n", num1, num2);
}//end if
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;
}//end function main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment