Quantcast
Viewing all articles
Browse latest Browse all 2703

IF Statement not working

I'm having problems getting my if statements to work properly, I believe the syntax is correct but the output is not what I expected. This is the code:

#include <stdio.h>

int main()

{
int num1;
int num2;

printf( "Relations between two numbers.\n" );
printf( "Please, enter the numbers: " );

scanf( "%d%d", &num1, &num2 );

if ( num1 == num2 );
{
printf( "%d is equal than %d\n", num1, num2 );
}

if ( num1 != num2 );
{
printf( "%d is different than %d\n", num1, num2 );
}

if ( num1 < num2 );
{
printf( "%d is less than %d\n", num1, num2 );
}

if ( num1 > num2 );
{
printf( "%d is greater than %d\n", num1, num2 );
}

if ( num1 <= num2 );
{
printf( "%d is less or equal than %d\n", num1, num2 );
}

if ( num1 >= num2 );
{
printf( "%d is greater or equal than %d\n", num1, num2 );
}

return 0;
}

And this is the output, which is obviously wrong:

Relations between two numbers.
Please, enter the numbers: 25 44
25 is equal than 44
25 is different than 44
25 is less than 44
25 is greater than 44
25 is less or equal than 44
25 is greater or equal than 44


What am I doing wrong? Any help would be greatly appreciated. Thanks in advance!!

Viewing all articles
Browse latest Browse all 2703

Trending Articles