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]
2 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]2 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
Before creating a brief to design a product, what is needed
castortr0y [4]

Answer:

A good design brief often begins with some information about the client and what their brand stands for. Including this helps to connect an individual project with the bigger picture. Aim to capture key points about what the company does, how big they are, and what their key products or services are.

Explanation:

A good design brief often begins with some information about the client and what their brand stands for. Including this helps to connect an individual project with the bigger picture. Aim to capture key points about what the company does, how big they are, and what their key products or services are.

8 0
3 years ago
Select the correct answer from each drop-down menu. Select the correct type of address reference.
Reika [66]

<u><em>[ Absolute ]</em></u><em> Addresses do not change if you copy them to a different cell.</em>

<u><em>[ Relative ]</em></u><em> </em><em>Addresses change depending on the cells you copy them to.</em>

8 0
2 years ago
Read 2 more answers
Which of the following is not a technology that can be used to conserve resources?
amm1812
<span>Natural gas when extracted through human industry will utilise resources to construct the necessary plant and machinery and then result in the consumption of a resource. Therefore this is the technology that cannot be seen as conserving resources.</span>
6 0
3 years ago
Read 2 more answers
Write a program that asks the user for three names, then prints the names in reverse order. Sample Run: Please enter three names
Sauron [17]

Solution:

Since no language was specified, this will be written in Python.

n1, n2, n3 = input ("Enter three names: ").split()

print(n3)

print(n2)

print(n1)

Cheers.

4 0
3 years ago
Fill in the blank. The process that a wireless router uses to translate a private IP address on internal traffic to a routable a
AleksandrR [38]

Answer:

Network Address Translation (NAT)

Explanation:

With the aid of Network address translation(NAT), the IP addresses of a particular local network are translated or mapped into a single or multiple global or public IP addresses. Therefore, a wireless router could use NAT to translate its private IP address on internal traffic (network) to a routable address for the internet.

With NAT, businesses can use many internal IP addresses since they are just for internal purposes and will be eventually converted into a single or a few multiple routable IP addresses.

Three types of NAT are possible:

(i) Static NAT : There is a one - to - one mapping between private IP addresses and routable (public) IP addresses. One private IP is mapped to one public IP address.

(ii) Dynamic NAT : There is a many- to - many mapping between private IP addresses and routable (public) IP addresses. Multiple private IPs are mapped to many public IP addresses.

(iii) Port Address Translation (PAT) : Many - to - one relationship between the private IP addresses and public addresses. Many private IP addresses can be mapped or translated into a single public IP address. This type of NAT is also called NAT overload.

6 0
3 years ago
Other questions:
  • After a robbery, what is the purpose of conducting a neighborhood canvass?
    9·1 answer
  • Which one of these tasks best describes the process of localization?
    12·1 answer
  • People using commercially available software are usually asked to read and agree to a(n) _____
    10·1 answer
  • What is one effective way for employees to keep their skillsets current?
    8·2 answers
  • How many dog breed are there
    9·2 answers
  • Which button in the Sort &amp; Filter gallery of the Data tab would alphabetize from A to Z quickly?
    6·2 answers
  • Explain the different type of shift register counter ​
    14·1 answer
  • I have a problem. I can't cycle between game packs on my strike pack, I've watched so many vids I'm on Xböx and I'm holding the
    13·1 answer
  • explain the following joke: “There are 10 types of people in the world: those who understand binary and those who don’t.”
    6·1 answer
  • One of the most notable impacts of IT on business is improved
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!