-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path06_first_n_even_reverse.c
43 lines (35 loc) · 972 Bytes
/
06_first_n_even_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
// // Write a recursive function to print first N Even natural numbers in reverse order.
// // Header Files
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
// // Function Declaration (Prototype)
void firstNEvenNaturalNumsReverse(int);
// // Main Function Start
int main()
{
int n;
printf("\nEnter N to Print First N Even Natural Numbers In Reverse Order => ");
scanf("%d", &n);
if (n < 0)
{
puts("\n!!! Invalid Input, Plz Enter Positive Number...");
exit(0);
}
printf("\n>>>>>>> First %d Even Natural Numbers In Reverse Order <<<<<<<\n", n);
firstNEvenNaturalNumsReverse(n);
putch('\n');
getch();
return 0;
}
// // Main Function End
// // Function Definition 👇👇
// // Recursive Function to Print First N Even Natural Numbers In Reverse Order
void firstNEvenNaturalNumsReverse(int n)
{
if (n > 0)
{
printf("%d ", n * 2);
firstNEvenNaturalNumsReverse(n - 1);
}
}