C Language while loop "Print Even And Odd Number Between 1 to 10" program with output
#include <stdio.h>
int main() { int num = 1; printf("Even numbers between 1 and 10:\n"); while (num <= 10) { if (num % 2 == 0) { printf("%d\n", num); } num++; } num = 1; // Reset num to 1 printf("\nOdd numbers between 1 and 10:\n"); while (num <= 10) { if (num % 2 != 0) { printf("%d\n", num); } num++; } return 0; }Output:
Even numbers between 1 and 10:
2
4
6
8
10
Odd numbers between 1 and 10:
1
3
5
7
9
Comments
Post a Comment