Day 3
Day 3
int main() {
int num;
if (num % 2 == 0) {
printf("%d is even.\n", num);
} else {
printf("%d is odd.\n", num);
}
return 0;
}
2. Program to Find the Largest of Three Numbers Using Nested If-Else
#include <stdio.h>
int main() {
int a, b, c;
if (a > b) {
if (a > c) {
printf("%d is the largest number.\n", a);
} else {
printf("%d is the largest number.\n", c);
}
} else {
if (b > c) {
printf("%d is the largest number.\n", b);
} else {
printf("%d is the largest number.\n", c);
}
}
return 0;
}
3. Program to Check the Grade Based on Marks Using Switch-Case
#include <stdio.h>
int main() {
int marks;
return 0;
}
4. Program to Print Numbers from 1 to 10 but Skip Numbers Divisible by 3
(Using Break and Continue)
#include <stdio.h>
int main() {
for (int i = 1; i <= 10; i++) {
if (i % 3 == 0) {
continue; // Skip the rest of the loop body if number is divisible by 3
}
printf("%d\n", i);
}
return 0;
}