Crafting a Unique C++ Program for Integer Scaling

Write a C (or C++) program to scale (amplify) an integer. It should take an integer from the user and use some pattern to display each digit of that integer in magnified form.

Example:

Input : 123
Output : 

  @
 @@
  @
  @
@@@@@
-------------------------------

@@@@
@  @
  @
 @
@@@@
-------------------------------


@@@@@
    @
@@@@@
    @
@@@@@
-------------------------------

This creative program takes an integer from the user, and then prints each bit of that integer after that integer to scale it.

The given number is first streamed using the conversion to string. Thereafter, each character (number) is accessed and placed in a switchbox structure that classifies each number and prints it in the form of a pattern.

Here’s the implementation of C++

//C++ program to zoon digits of an integer
#include <bits/stdc++.h>
using namespace std;
  
void zoomDigits( int number)
{
     //Converting number to string
     stringstream ss;
     ss <<number;
     string str = ss.str();
  
     for ( int k=0; k<str.length(); k++)
     {
         switch (str[k]- '0' )
         {
         case 0:
             for ( int i=0; i<5; i++)
             {
                 for ( int j=0; j<5; j++)
                 {
                     if (i==0 || i==4)
                         cout <<'@' ;
                     else if (j==0 || j==4)
                         cout <<'@' ;
                     else
                         cout <<" " ;
  
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
  
         case 1:
             for ( int i=0; i<5; i++)
             {
                 for ( int j=0; j<5; j++)
                 {
                     if (j==2)
                         cout <<'@' ;
                     else if ((i==1 && j==1))
                         cout <<'@' ;
                     else if (i==4)
                         cout <<'@' ;
                     else
                         cout <<" " ;
  
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
  
         case 2:
             for ( int i=0; i<5; i++)
             {
                 for ( int j=0; j<4; j++)
                 {
                     if (i==0 && j==4)
                         cout <<" " ;
                     else if (i==0 || i==4)
                         cout <<'@' ;
                     else if (i==1 && j==0)
                         cout <<'@' ;
                     else if (i==(4-j))
                         cout <<'@' ;
                     else
                         cout <<" " ;
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
  
         case 3:
             for ( int i=0; i<5; i++)
             {
                 for ( int j=0; j<5; j++)
                 {
                     if (i==0 || i==2 || i==4)
                         cout <<'@' ;
                     else if (j==4)
                         cout <<'@' ;
                     else
                         cout <<" " ;
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
  
         case 4:
             for ( int i=0; i<5; i++)
             {
                 for ( int j=0; j<5; j++)
                 {
                     if (j==4)
                         cout <<'@' ;
                     else if (i==2)
                         cout <<'@' ;
                     else if (j==0 && (i==0 || i==1))
                         cout <<'@' ;
                     else
                         cout <<" " ;
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
  
         case 5:
             for ( int i=0; i<5; i++)
             {
                 for ( int j=0; j<5; j++)
                 {
                     if (i==0 || i==2 || i==4)
                         cout <<'@' ;
                     else if ((j==0 && i==1) ||
                              (j==4 && i==3))
                         cout <<'@' ;
                     else
                         cout <<" " ;
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
  
         case 6:
             for ( int i=0; i<5; i++)
             {
                 for ( int j=0; j<5; j++)
                 {
                     if (i==0 || i==2 || i==4)
                         cout <<'@' ;
                     else if ((j==0 && (i==1 || i==3)) ||
                                        (j==4 && i==3))
                         cout <<'@' ;
                     else
                         cout <<" " ;
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
  
         case 7:
             for ( int i=0 ; i<5; i++)
             {
                 for ( int j=0 ; j<5; j++)
                 {
                     if (i==0 && (j!=4))
                         cout <<'@' ;
                     else if (i==2 && (j==2 || j==4))
                         cout <<'@' ;
                     else if (j==3)
                         cout <<'@' ;
                     else
                         cout <<" " ;
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
  
         case 8:
             for ( int i=0; i<5; i++)
             {
                 for ( int j=0; j<5; j++)
                 {
                     if (i==0 || i==2 || i==4)
                         cout <<'@' ;
                     else if ((j==0 && (i==1 || i==3) ||
                             (j==4 && (i==1 || i==3))))
                         cout <<'@' ;
                     else
                         cout <<" " ;
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
  
         case 9:
             for ( int i=0; i<5; i++)
             {
                 for ( int j=0; j<5; j++)
                 {
                     if ( i==0 || i==2 || j==4)
                         cout <<'@' ;
                     else if (i==1 && j==0)
                         cout <<'@' ;
                     else
                         cout <<" " ;
                 }
                 cout <<endl;
             }
             cout <<"-------------------------------\n\n" ;
             continue ;
         }
     }
}
  
//Driver code
int main()
{
     long long number = 12305;
     zoomDigits(number);
     return 0;
}

The output is as follows:

@
 @@
  @
  @
@@@@@
-------------------------------

@@@@
@  @
  @
 @
@@@@
-------------------------------

@@@@@
    @
@@@@@
    @
@@@@@
-------------------------------

@@@@@
@   @
@   @
@   @
@@@@@
-------------------------------

@@@@@
@
@@@@@
    @
@@@@@
-------------------------------

If you find anything incorrect, or would like to share more information about the above topics, please write a comment.

Considered one of the most sought-after skills in the industry, we have our own coding foundation, C++ STL, to train and master these concepts through an intense problem-solving process.