1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Levart [38]
3 years ago
8

2. Integer plot function (find a smart way to code big integers) Write a program BigInt(n) that displays an arbitrary positive i

nteger n using big characters of size 7x7, as in the following example for BigInt(170): @@@@@@ @@ @@@@@ Write a demo main program that illustrates the work of BigInt(n) and prints the following sequence of big numbers 1, 12, 123, 1234, ..., 1234567890, one below the other.

Computers and Technology
1 answer:
Shalnov [3]3 years ago
4 0

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.

You might be interested in
Implement a simplified version of a crypto broker platform. Initially, there is an array of users, with each user depositing onl
Salsk061 [2.6K]
Jriririiekeekekkksks
3 0
3 years ago
What is the Most popular game out today?
belka [17]

Answer:

Roblox

Explanation:

People over a million people are playing that game FAM!!!

7 0
3 years ago
Read 2 more answers
Ayuda no encuentro la información de estas tres preguntas:
Morgarella [4.7K]

Answer:

Sorry i don't know.........!!!!!!!!!!

Explanation:

3 0
3 years ago
How much space should be allotted to park your vehicle parallel to the curb?
alexandr1967 [171]

there is no definite answer. so long as you are not touching another vehicle or in the road.

6 0
3 years ago
"Na2SO3” represents sodium sulfite.
STatiana [176]
There are four atoms
5 0
3 years ago
Read 2 more answers
Other questions:
  • A customer has contacted you to help him alleviate the large amount of time and effort that goes into adding and removing users
    12·1 answer
  • How might writing an online journal be different than writing in a paper one ​
    15·2 answers
  • Develop a Java program that determines the gross pay for an employee. The company pays hourly rate for the first 40 hours worked
    8·1 answer
  • When you want to avoid sending email that a recipient may feel their privacy has been invaded, how would you fill in the (To) bo
    13·1 answer
  • Fill in the blank: _________ is Google’s machine-learning artificial intelligence system that interprets people’s searches to fi
    9·1 answer
  • Discuss briefly four types of websites and the criteria you will use to evaluate the content of a website
    8·1 answer
  • Communication protocols, sets of rules agreed to by all parties, are designed in order to:
    15·1 answer
  • Create a basic program that accomplishes the following requirements: Allows the user to input 2 number , a starting number x and
    12·1 answer
  • Please help me plss! PLS​
    8·2 answers
  • Give a common business example that mimics the differences between a shared
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!