Answer:
The program is coded in C++ language, Complete code along with explanation and output is provided below.
C++ Code:
#include <iostream>
using namespace std;
void print(int N, int L);
void big_int(int num)
{
int L;
int N;
int count = 0;
int array[100];
while(num > 0)
{
int digit = num % 10;
array[count] = digit;
num = num/10;
count++;
}
for(L = 1; L <= 7; L++) // for 7 lines
{
for(N = count - 1; N >= 0; N--)
{
print(array[N], L); // call the print function
}
cout<<endl;
}
return;
}
void print(int N, int L)
{
switch(N)
{
case 0:
if(L == 1){ cout<<" ***** ";}
else if(L == 2){ cout<<"** ** ";}
else if(L == 3){ cout<<"** ** ";}
else if(L == 4){ cout<<"** ** ";}
else if(L == 5){ cout<<"** ** ";}
else if(L == 6){ cout<<"** ** ";}
else if(L == 7){ cout<<" ***** ";}
else{cout<<"Invalid line"<<endl;}
break;
case 1:
if(L == 1){ cout<<" *** ";}
else if(L == 2){ cout<<"***** ";}
else if(L == 3){ cout<<" *** ";}
else if(L == 4){ cout<<" *** ";}
else if(L == 5){ cout<<" *** ";}
else if(L == 6){ cout<<" *** ";}
else if(L == 7){ cout<<"******* ";}
else{cout<<"Invalid line"<<endl;}
break;
case 2:
if(L == 1){ cout<<" ***** ";}
else if(L == 2){ cout<<"** ** ";}
else if(L == 3){ cout<<" ** ";}
else if(L == 4){ cout<<" ** ";}
else if(L == 5){ cout<<" ** ";}
else if(L == 6){ cout<<" *** ";}
else if(L == 7){ cout<<"******* ";}
else{cout<<"Invalid line"<<endl;}
break;
case 3:
if(L == 1){ cout<<" ***** ";}
else if(L == 2){ cout<<"* ** ";}
else if(L == 3){ cout<<" *** ";}
else if(L == 4){ cout<<" **** ";}
else if(L == 5){ cout<<" *** ";}
else if(L == 6){ cout<<"* ** ";}
else if(L == 7){ cout<<" ***** ";}
else{cout<<"Invalid line"<<endl;}
break;
case 4:
if(L == 1){ cout<<" ** ";}
else if(L == 2){ cout<<" *** ";}
else if(L == 3){ cout<<" * ** ";}
else if(L == 4){ cout<<"* ** ";}
else if(L == 5){ cout<<"******* ";}
else if(L == 6){ cout<<" ** ";}
else if(L == 7){ cout<<" ** ";}
else{cout<<"Invalid line"<<endl;}
break;
case 5:
if(L == 1){ cout<<"******* ";}
else if(L == 2){ cout<<"** ";}
else if(L == 3){ cout<<"** ";}
else if(L == 4){ cout<<"****** ";}
else if(L == 5){ cout<<" ** ";}
else if(L == 6){ cout<<"* ** ";}
else if(L == 7){ cout<<" ***** ";}
else{cout<<"Invalid line"<<endl;}
break;
case 6:
if(L == 1){ cout<<" ***** ";}
else if(L == 2){ cout<<"** ** ";}
else if(L == 3){ cout<<"** ";}
else if(L == 4){ cout<<"****** ";}
else if(L == 5){ cout<<"** ** ";}
else if(L == 6){ cout<<"** ** ";}
else if(L == 7){ cout<<" ***** ";}
else{cout<<"Invalid line"<<endl;}
break;
case 7:
if(L == 1){ cout<<"******* ";}
else if(L == 2){ cout<<"** ** ";}
else if(L == 3){ cout<<" ** ";}
else if(L == 4){ cout<<" ** ";}
else if(L == 5){ cout<<" ** ";}
else if(L == 6){ cout<<" ** ";}
else if(L == 7){ cout<<" ** ";}
else{cout<<"Invalid line"<<endl;}
break;
case 8:
if(L == 1){ cout<<" ***** ";}
else if(L == 2){ cout<<"** ** ";}
else if(L == 3){ cout<<"** ** ";}
else if(L == 4){ cout<<"******* ";}
else if(L == 5){ cout<<"** ** ";}
else if(L == 6){ cout<<"** ** ";}
else if(L == 7){ cout<<" ***** ";}
else{cout<<"Invalid line"<<endl;}
break;
case 9:
if(L == 1){ cout<<" ***** ";}
else if(L == 2){ cout<<"** ** ";}
else if(L == 3){ cout<<"** ** ";}
else if(L == 4){ cout<<" ****** ";}
else if(L == 5){ cout<<" ** ";}
else if(L == 6){ cout<<"** ** ";}
else if(L == 7){ cout<<" ***** ";}
else{cout<<"Invalid line"<<endl;}
break;
default:
{cout<<"Invalid Input!"<<endl;}
}
}
// driver code
int main()
{
big_int(123);
big_int(123456);
big_int(123456789);
return 0;
}
Explanation:
We have created two functions:
1. void print(int N, int L)
This function is used to print numbers and contains the individual big integers of the size 7 by 7. A switch method is used to select correcting digit. It takes two input arguments, N is the number from 0 to 9 and L is the line number.
2. void big_int(int num)
This function is used to implement the logic. A while loop is used until all N numbers are printed. One for loop calls the print function inside a for loop to print the numbers. Another loop is used to for the 7 rows to start new lines.
In the driver code, we called the big_int function to print several numbers.
Output:
Please refer to the attached image.