Skip to content

Instantly share code, notes, and snippets.

@Sanokei
Created November 3, 2021 01:39
Show Gist options
  • Save Sanokei/532c09cb72cbea4d13f81f84788e099d to your computer and use it in GitHub Desktop.
Save Sanokei/532c09cb72cbea4d13f81f84788e099d to your computer and use it in GitHub Desktop.
#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