Question

Number Pattern - Square number pattern - 10 Given two integers N1 and N2, display the...

Number Pattern - Square number pattern - 10

Given two integers N1 and N2, display the given number pattern(Square number patterns).

in zinger code with comment please

Input:
5

5

    where:

  • First line represents the value of N1( number of rows ).
  • Second line represents the value of N2( number of columns ).

Output:

1 1 1 1 1

   2 2 2 2 2

   3 3 3 3 3

   4 4 4 4 4

5 5 5 5 5

Homework Answers

Answer #1

Note that you have'nt mentioned any language.So I have coded it in C++.Although you can change it in any language if you understand the algorithm.

//Code starts here.

#include <iostream>

using namespace std;

int main()
{
int N1,N2; //Integers for N1 and N2
cin>>N1>>N2; //Taking input for N1 and N2
int i,j; //Variables for loops
for(i=1;i<=N1;i++) //Outer loop,will run for N1(no. of rows) times
{
if(i!=1&&i!=N1) //Print extra space every row except first and last
cout<<" ";
for(j=1;j<=N2;j++) //Inner loop,will run for N2(no. of columns) times
{
cout<<i<<" "; //Print value of i
  
}
cout<<endl; //Change line after every row
}
return 0;
}
//Code ends here

Output

Python code

#Code starts here


#First take N1 and N2 as input after converting into int
N1 =int(input())
N2 =int(input())

for i in range(1,N1+1): #will run from 1 to N1(no of rows)
if i!=1 and i!=N1: #For empty spaces except first and last row
print(end=' ')
for j in range(1,N2+1): #will run for N2 times(no. of columns)
print (i,end=' ')
print() #Line change
#End of program

Output for two runs

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
Linux 2)   Write a bash script which when executed, expects two integers, say n1 and n2....
Linux 2)   Write a bash script which when executed, expects two integers, say n1 and n2. If the first argument, n1, is greater than the second argument, n2, the script calls a function (written within the script) and passes to the function n1 and n2 to compute the sum from n1 to n2. This function returns the sum which the script prints. If n1 is not greater than n2, the script calls the same function and passes the n1 and...
(8 marks) Write a program to ask user to input an integer and display the special...
Write a program to ask user to input an integer and display the special pattern accordingly. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use loop statements (for, while or do-while). Your program should use only the following 3 output statements, one of EACH of the followings: System.out.print("-"); // print # System.out.print("+"); // print + System.out.println(); // print a newline Your code must work exactly like the following example (the text in bold...
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,...
Given two independent random samples with the following results: n1 = 226 ^p1 = 0.55 n2...
Given two independent random samples with the following results: n1 = 226 ^p1 = 0.55 n2 = 444 ^p2 = 0.63 Can it be concluded that the proportion found in Population 2 exceeds the proportion found in Population 1?  Use a significance level of α=0.1 for the test. Step 1 of 5: State the null and alternative hypotheses for the test. Step 2 of 5: Compute the weighted estimate of p, p‾. Round your answer to three decimal places. Step 3...
Given two independent random samples with the following results: n1 = 11            n2 = 13...
Given two independent random samples with the following results: n1 = 11            n2 = 13 xbar1 = 162 xbar^2 = 130 s1 = 31 s2 = 30 Use this data to find the 95% confidence interval for the true difference between the population means. Assume that the population variances are equal and that the two populations are normally distributed. Copy Data Step 1 of 3: Find the critical value that should be used in constructing the confidence interval. Round...
Given two independent random samples with the following results: n1=462 pˆ1=0.24   n2=599 pˆ2=0.41 Can it be...
Given two independent random samples with the following results: n1=462 pˆ1=0.24   n2=599 pˆ2=0.41 Can it be concluded that the proportion found in Population 2 exceeds the proportion found in Population 1? Use a significance level of α=0.01 for the test. Step 2 of 5 : Compute the weighted estimate of p, p‾‾. Round your answer to three decimal places. Step 3: Compute the value of the test statistic. Round to two decimal places. Step 4: Determine the decision rule
Given two independent random samples with the following results: n1=462 pˆ1=0.24   n2=599 pˆ2=0.41 Can it be...
Given two independent random samples with the following results: n1=462 pˆ1=0.24   n2=599 pˆ2=0.41 Can it be concluded that the proportion found in Population 2 exceeds the proportion found in Population 1? Use a significance level of α=0.01 for the test. Step 2 of 5 : Compute the weighted estimate of p, p‾‾. Round your answer to three decimal places. Step 3: Compute the value of the test statistic. Round to two decimal places. Step 4: Determine the decision rule
Two independent random samples of sizes n1= 4 and n2=5 are selected from each of two...
Two independent random samples of sizes n1= 4 and n2=5 are selected from each of two normal populations: Population 1: 12 3 8 5 Population 2: 14 7 7 9 5 use a=0.5 What is the correct Test Statistic: A. 5.2889 B. 2.795 C. 2.771 D. 2.575
Given two independent random samples with the following results: n1=592 p^1=0.87   n2=408 pˆ2=0.53    Use this...
Given two independent random samples with the following results: n1=592 p^1=0.87   n2=408 pˆ2=0.53    Use this data to find the 90% confidence interval for the true difference between the population proportions. Step 2 of 3 :   Find the value of the standard error. Round your answer to three decimal places.
An urn contains 64 balls, of which N1 are orange and N2 are blue. A random...
An urn contains 64 balls, of which N1 are orange and N2 are blue. A random sample of n = 8 balls is selected from the urn without replacement, and X is equal to the number of orange balls in the sample. This experiment was repeated 30 times (the 8 balls being returned to the urn before each repetition), yielding the following data: Table 1: Data for Q2 3 0 0 1 1 1 1 3 1 1 2 0...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT