#include <stdio.h> int main() { int x=1,n; printf("Enter n value "); scanf("%d",&n); do { if(x%2==0 && n%2==0) { printf("%d\n",x); } else if(x%2!=0 && n%2!=0) { printf("%d\n",x); } x++; }while(x<=n); return 0; }
Enter n value 20
2
4
6
8
10
12
14
16
18
20
Enter n value 21
1
3
5
7
9
11
13
15
17
19
21