-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path05_first_10_odd_natural_reverse.c
82 lines (69 loc) · 1.71 KB
/
05_first_10_odd_natural_reverse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// // C program to print the first 10 odd natural numbers in reverse order
// // Header Files
#include <stdio.h>
#include <conio.h>
// // Main Function Start
int main()
{
printf("\n>>>>>>>>> First 10 Odd Natural Numbers In Reverse Order <<<<<<<<<\n");
// // 1st Approach (using while loop)
int i = 10;
while (i)
{
printf("\n%d", i * 2 - 1);
i--;
}
// // 2nd Approach (using while loop)
// // int i = 19;
// // while (i > 0)
// // {
// // printf("\n%d", i);
// // i -= 2;
// // }
// // 3rd Approach (using while loop)
// // int i = 19;
// // while (i)
// // {
// // if (i % 2)
// // printf("\n%d", i);
// // i--;
// // }
// // 4th Approach (using do-while loop)
// // int i = 10;
// // do
// // {
// // printf("\n%d", i * 2 - 1);
// // i--;
// // } while (i);
// // 5th Approach (using do-while loop)
// // int i = 19;
// // do
// // {
// // printf("\n%d", i);
// // i -= 2;
// // } while (i > 0);
// // 6th Approach (using do-while loop)
// // int i = 19;
// // do
// // {
// // if (i % 2)
// // printf("\n%d", i);
// // i--;
// // } while (i);
// // 7th Approach (using for loop)
// // for (int i = 10; i; i--)
// // printf("\n%d", i * 2 - 1);
// // 8th Approach (using for loop)
// // for (int i = 19; i > 0; i -= 2)
// // printf("\n%d", i);
// // 9th Approach (using for loop)
// // for (int i = 19; i; i--)
// // {
// // if (i % 2)
// // printf("\n%d", i);
// // }
printf("\n");
getch();
return 0;
}
// // Main Function End