if (condition) {
// Code to be executed if the condition is true
} else {
// Code to be executed if the condition is false
}
#include <stdio.h>
int main() {
int num = 10;
// Check if num is even or odd
if (num % 2 == 0) {
printf("%d is even.\n", num);
} else {
printf("%d is odd.\n", num);
}
return 0;
}
if (condition1) {
// Code to be executed if the condition1 is true
} else if(condition2) {
// Code to be executed if the condition1 is false and condition2 is true
} else {
// Code to be executed if all conditions are false
}
#include <stdio.h>
int main() {
int score = 75;
// Grading based on the score
if (score >= 90) {
printf("Grade A\n");
} else if (score >= 80) {
printf("Grade B\n");
} else if (score >= 70) {
printf("Grade C\n");
} else {
printf("Grade F\n");
}
return 0;
}
The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compiler.