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 47 48 49 50 51 |
/* Comparing two number using if statements,Relational operators, and equality operators */ #include <stdio.h> #include <conio.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 */ printf("\t\t\t\t\tWelcome to"); printf("\t\t\t\t\tComparing Software"); delay(2000); clrscr(); printf("\t\t\t\t\tCoded By:"); printf("\t\t\t\t\twww.bestengineeringprojects.com"); delay(2000); clrscr(); printf( "Enter two integers, you want to compare\n" ); printf( "and this software tell you the relationships they satisfy: " ); scanf( "%d%d", &num1, &num2 ); /* read two integers */ getch(); 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 ); getch(); } /* end if */ return 0; /* indicate that program ended successfully */ } /* end function main */ |
Click Here to download Compiled Software
The output of the Program are shown in figure below: