-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC++ Recursion CountFromTo.cpp
More file actions
42 lines (29 loc) · 1.02 KB
/
C++ Recursion CountFromTo.cpp
File metadata and controls
42 lines (29 loc) · 1.02 KB
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
/**
[PROGRAM] : C++ Recursion
[AUTHOR] : Saddam Arbaa
[Email] : <saddamarbaas@gmail.com>
Recursive Program to print numbers between given
two numbers */
#include <iostream>
using namespace std;
void CountFromTo(int n, int); // Function declaration
int main() // the main Function
{
int star, end; // variable declaration
cout << "Enter start number :"; // asking user input
cin >> star;
cout << "Enter end number :"; // asking user input
cin >> end;
CountFromTo(star, end); // call the function
return 0;// signal to operating system everything works fine
}/** End of main function */
/**
Recursive function to print Numbers
between given two numbers by user */
void CountFromTo(int start, int end)
{
if(start == end) return ; /* Terminating condition(base case)*/
printf("counter = %d\n",start); // print the number
// decrement start and recusive call again
CountFromTo(start + 1, end); // Recursive call
}/** End of Count_Recursively()*/