Question

Print the following two patterns using nested loops. Pattern 1 13579 13579 13579 13579 Pattern 2...

Print the following two patterns using nested loops. Pattern 1 13579 13579 13579 13579 Pattern 2 #####1 ####12 ###123 ##1234 #12345

Homework Answers

Answer #1

language c++

Pattern 1

#include <iostream>

using namespace std;

int main()
{
    int k=1;
    for(int i=1;i<=4;i++){
        for(int j=1;j<=5;j++){
            
            cout<<k;
            k+=2;
        }
            cout<<endl;
            k=1;
            
    }
    

    return 0;
}

output ->

13579

13579

13579

13579

pattern 2

#include <iostream>

using namespace std;

int main()
{
    int k=1;
    for(int i=1;i<=5;i++){
        for(int j=1;j<=6;j++){
            
             if(j<=6-i){
            cout<<"#";
            }
            else
            {
            cout<<k++;        
            }
            
        }
            cout<<endl;
            k=1;
            
    }
    

    return 0;
}

output->

#####1

####12

###123

##1234

#12345

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
PYTHON 1.      Complete the attached template program pattenrs.py to create and display a number of patterns. The...
PYTHON 1.      Complete the attached template program pattenrs.py to create and display a number of patterns. The program works with a single digit. The default value is 6, but user to change it as a menu selection. 2.      Program should display the patterns below. Additionally, you need to create your own pattern. 3.      Do not modify myPatterns6 driver. 4.      Make sure you document the program and its functions. 5.      PatternI is already implemented. 6.      Create five additional functions (similar to PatternI function) to implement Patterns II,...
I need gelp with writing a c++ code using visual studios to print out this pattern,...
I need gelp with writing a c++ code using visual studios to print out this pattern, please: 1******        12*****        123****        1234***        12345**        123456*        1234567
Write a nested FOR loop (using two for loops & two fprintf statements to generate the...
Write a nested FOR loop (using two for loops & two fprintf statements to generate the following pattern: ***** **** *** ** *
Create a Java application using nested for loops to print five rows of seven randomly generated...
Create a Java application using nested for loops to print five rows of seven randomly generated integers between 1 and 9 inclusive.
In c++, use nested loops to print a matrix with all the even numbers from 1...
In c++, use nested loops to print a matrix with all the even numbers from 1 to 80 displayed in 5 rows and 8 columns.
4.9.1: Nested loops: Indent text. JAVA Print numbers 0, 1, 2, ..., userNum as shown, with...
4.9.1: Nested loops: Indent text. JAVA Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex: userNum = 3 prints: 0 1 2 3 Please use my template import java.util.Scanner; public class...
write a Nested loop in C# to print out the following output using windows form. 0...
write a Nested loop in C# to print out the following output using windows form. 0 0 1 0 2 4 0 3 6 9 0 4 8 16 32
Using nested loops, write a function called primes(a,b) that takes in two positive integers a and...
Using nested loops, write a function called primes(a,b) that takes in two positive integers a and b (where a<b). Then simply RETURNS a string containing all the prime numbers between a and b (or if there are none, the string "No Primes"). You should check that a and b are valid inputs, that is, that a and b are integers such that a<b (otherwise, the function should print “No Primes”). Three sample calls of your function (in IDLE) should produce...
Python Code Use (for loops) inside another for loop (a nested loop) to do the following:...
Python Code Use (for loops) inside another for loop (a nested loop) to do the following: Print Hello 30 times followed by Bye 10 times. Do that whole thing 15 times. (for a total of 600 lines of output) #Hint: First write the code that prints 30 "Hello" and then 10 "Bye". Think of that as two separate tasks, each of which requires its own for loop. THEN, once you get that working, put all of that inside ANOTHER loop...
Are fingerprint patterns genetic, or are they developmental? In 1892 Francis Galton compiled the following table...
Are fingerprint patterns genetic, or are they developmental? In 1892 Francis Galton compiled the following table on the relationship between the patterns on the same finger of 105 sibling pairs. Test the hypothesis that the patterns are independent for example, that knowing one sibling (A) has a Whorl on the finger does not help in predicting the pattern of the other (B). A children B children Arches   Loops Whorls Totals Arches 5 12 2 19 Loops 4 42 15 61...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT