I'm sorry if this has been asked before, but I'm a beginner to C and I was wondering if someone could help explain the use of the () brackets in the following code.
I took it from an online tutorial and it runs fine, but there's one part of it I don't understand.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int age;
printf("Please enter the age");
scanf("%d", &age);
if (age > 18 /*condition */ ) {
printf("You may enter the club");
if (age < 21)
{
printf("The age is greater than 18 but less than 21");
} else
(printf("The age is greater than 18 and greater than 21"));
} else if (age == 18)
{
printf("The age is equal to 18");
}
else {
printf("The age is not greater than 18");
}
return 0;
}
From what I've gathered the round brackets are used to contain the conditions of an if statement, and the curly brackets are used to state the operation which follows that condition. Except for the nested else condition in bold, where the else statement is followed by a round brackets enclosing the print command.
Could anyone explain why this is so?