use a conditional to check greater than number in C
Code snippet on how to use a conditional to check greater than number in C
int num1 = 5, num2 = 4;
if(num1 > num2)
{
printf("num1 is greater than num2");
}
In this code, two integers are declared and initialized with values 5 and 4 respectively. Then, the if statement is used to compare the value of the two integers and depending on which is the bigger number the conditional will be executed and “num1 is greater than num2” is printed out. The if statement is followed by a pair of curly braces ({}) which indicate which code will be executed and the condition being checked is written within the parenthesis. The greater than comparison is denoted by the ‘>’ operator that follows the two integers being compared. The if statement is a commonly used control structure used to check certain conditions.