by CodeChum Admin
In life, good things take time.
Let's make a simple program that mirrors this beautiful idea where we ask the user for two integer inputs. The first one would represent the starting number and the second one would represent the next n integers after it.
For example, if the first number inputted is 2 and the second number inputted is 3, then the output would be 3, 4, 5 because these are the next 3 integers after 2.
Instructions:
Input
1. Starting integer
2. Number of integers
Output
Enter·starting·integer:·2
Enter·how·many·next·integers:·3
3·4·5
#include <iostream>
using namespace std;
void slowDisplay(int start,int n)
{
while (n>0)
{
start++;
n--;
cout << start << " ";
return slowDisplay(start, n);
}
}
int main()
{
int start, next;
cout << "Please, enter starting integer: ";
cin >> start;
cout << "Please, enter how many next integers: ";
cin >> next;
slowDisplay(start, next);
}
Comments
Leave a comment