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
Write an algorithm to get the value of length and breadth of a rectangle from the user and find its area. inn qbasic
Shalnov [3]

Answer:

IN PYTHON ::

x=int(input('Enter length:'))

y=int(input('Enter width:'))

print('Area of the rectangle is', x*y,'squared units')

I hope it will be useful.

5 0
3 years ago
Discuss the major differences in two approaches ofprogramming i.e. Object oriented programming and structuredprogramming.
Romashka-Z-Leto [24]

Answer:

Differences between Object Oriented Programming and Structured Programming

1. Structured programming focuses on process/logic then data while OOP(Object Oriented programming) focuses on data.

2.OOP supports Inheritance,Encapsulation,Abstraction,Polymorphism while structured programming does not supports these.

3.Structured programming follows top-down approach while OOP follows bottom-up approach.

4.OOP is more secured than structured programming because it supports Abstraction (data hiding).

7 0
3 years ago
Develop a simple game that teaches kindergartners how to add single-digit numbers. Your function game() will take an integer n a
Lyrx [107]

Answer:

2 correct answer out of 3

5 0
3 years ago
ANSWER QUICKLY!
patriot [66]

Answer:

It is bit { measurement used to quantify computer data. }

7 0
3 years ago
Compute the monthly cost of gas.
aalyn [17]

Answer:

Attached excel file containing formula for monthly cost of gas.

Explanation:

To find mileage note down readings at the star of month and at end of month.

Subtract end of month reading from start this will give you number of miles in month. Now as per mentioned in question, divide number of miles by average mpg and multiply by the price of a gallon of gas.

Here is your monthly cost of gas.

Download xlsx
6 0
3 years ago
Other questions:
  • Help asap. 10 points.
    8·2 answers
  • A short-circuit evaluation is where each part of an expression is evaluated only as far as necessary to determine whether the en
    14·1 answer
  • Examine the evolution of the World Wide Web (WWW) in terms of the need for a general-purpose markup language. Provide your persp
    5·1 answer
  • With landscape photography, which depth of field do you normally want? A) Small B)Small to Medium C)Large D)With landscapes it d
    7·2 answers
  • А.<br> is the highest education degree available at a community college.
    6·1 answer
  • Give an example of a process that may need a flowchart to clarify procedures.<br><br> HELP ASAP!
    7·1 answer
  • How are computers used in producing weather forecasts?
    8·1 answer
  • In the Microsoft Excel spreadsheet how many choices are possible when using a single IF statement​
    9·1 answer
  • A homeowner uses a smart assistant to set the house alarm, get packages delivery updates, and set time on the outdoor lights. Wh
    14·1 answer
  • Why is technology bad for you
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!