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
kvasek [131]
3 years ago
10

Write a program that prints the following 45 pairs of numbers:

Computers and Technology
1 answer:
nadezda [96]3 years ago
8 0

Here is code in C++ to print the following 45 pairs of numbers:

11 21 22 31 32 33 41 42 43 44 51 ...

// include header

#include <bits/stdc++.h>

using namespace std;

//main function

int main() {

//declare variables

int count=0;

int flag=1;

// for loop to print the pattern

for(int i=1;;i++)

{

for(int j=1;j<=i;j++)

  {

// this will print the pairs in vertical manner

     cout<<i<<j<<endl;

//cout<<i<<j<<""; //this will print horizontally

// this will keep count to print only 45 pairs

count++;

// if count is equal to 45 then it will break the inner loop

     if(count==45)

     {

         flag=0;

         break;

     }

}

   // if the flag is eqaul to 45 then it will break the outer loop

   if(flag==0)

     break;

}

return 0;

}

Explanation:

First declare and initialize two variables "count=0" & "flag=1". Here variable

"count" is use to print only 45 pairs and "flag" is used to break the loop when 45 pairs of numbers are printed.In the nested for loop, for every value of i,j will run from 1 to i and print i then j without any space. After every pair, count will incremented by 1. It will check if "count" is greater than 45 or not. If "count" is greater than 45 then it make flag=0 and break the loop. in the outer for loop, if flag is 0 then it break the outer for loop.

Output:

11 21 22 31 32 33 41 42 43 44 51 52 53 54 55 61 62 63 64 65 66 71 72 73 74 75 76 77 81 82 83 84 85 86 87 88 91 92 93 94 95 96 97 98 99

You might be interested in
Which of the following is least likely to be a scientific experiment?
enot [183]
It would be the last one, because she isn't recording any type of data over what she is doing and she isn't observing it at all. She simply trimmed the stems of a bouquet of flowers. However, the other options insist that they are recording data and observing, like you would do when performing an experiment. I hope this helps! :)
8 0
3 years ago
Read 2 more answers
In each iteration, selection sort (small) places which element in the correct location?
Jet001 [13]
The answer is <span>smallest not yet placed.  </span><span>In each iteration, selection sort  places smallest not yet placed element in the correct location.  </span>
7 0
3 years ago
1) These are operators that add and subtract one from their operands. A) plus and minusB) ++ and --C) binary and unaryD) conditi
GREYUIT [131]

Answer:

1) B: ++ and --

2) B: 111... and on forever

Explanation:

++ and -- in most programming languages are used for incrementing(adding) by 1 or decrementing(substracting) by 1.

The code will output 111... and on forever because the while loop was not covered in curly braces.

5 0
3 years ago
You have the following code:
My name is Ann [436]

Answer:

7

Explanation:

We already have the functions that tells us how much to add. If you add all this, you will get 12. HOWEVER because cantaloupe is in the list, the computer does not count that. So if we add that again without 5(how much the cantaloupe costs), we get 7.

3 0
2 years ago
My texts to people keep disapearring snd id k what to do. i text through pad let.
MakcuM [25]

Answer:

oh that sad am bored who eles is bored

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • You create hidden form fields with the ____ element.
    9·1 answer
  • Distinguish between multiprogramming and multiprocessing. What were the key motivations for the development of each?
    14·1 answer
  • Chevening is looking for individuals with strong professional relationship building skills, who will engage with the Chevening c
    15·1 answer
  • Why might your coworker suggest encrypting an archive file before e-mailing it??
    8·1 answer
  • Which of the following statements is not true? Group of answer choices
    9·1 answer
  • A Raycast returns a float that tells you how far away an Object is
    8·1 answer
  • python Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value i
    7·1 answer
  • How to find out what version of windows i have?
    13·1 answer
  • Order the steps to use a logical argument as a rule type.
    15·2 answers
  • How do you create a turtle in python again-
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!