Created
November 3, 2021 01:39
-
-
Save Sanokei/532c09cb72cbea4d13f81f84788e099d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int digitBar(int num) | |
{ | |
if (num < 10) | |
{ | |
for (int i = 0; i < num; i++) | |
{ | |
cout << "*"; | |
} | |
cout << endl; | |
} | |
else | |
{ | |
for (int i = 0; i < num % 10; i++) | |
{ | |
cout << "*"; | |
} | |
cout << endl; | |
digitBar(num / 10); | |
} | |
} | |
int main() | |
{ | |
int num; | |
cout << "Enter a number: "; | |
cin >> num; | |
//reverse the number | |
int rev = 0; | |
while (num > 0) | |
{ | |
rev = rev * 10 + num % 10; | |
num = num / 10; | |
} | |
num = rev; | |
digitBar(num); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment