Striped Rectangle
Given an integer number
The first line of input is an integer
In the given example the striped rectangular pattern of
7 rows and 5 columns. Therefore, the output should be
M=int[input[]]
N=int[input[]]
for i in range[M]:
for j in range[N]:
if [i%2==0]:
print["+",end=" "]
else:
print["-",end=""]
print[]
Learn more about our help with Assignments: Python
Given an integer number M, N as input. Write a program to print a striped rectangular pattern of M rows and N columns using [+ and -] character.
The first line of input is an integer M.
The second line of input is an integer N.
In the given example the striped rectangular pattern of
7 rows and 5 columns. Therefore, the output should be
+ + + + +
- - - - -
+ + + + +
- - - - -
+ + + + +
- - - - -
+ + + + +
View Discussion
Improve Article
Save Article
View Discussion
Improve Article
Save Article
Hollow rectangle star pattern :
The task is print below hollow pattern of given dimension.
******************** * * * * * * * * ********************
Explanation:
- Input number of rows and columns.
- For rows of rectangle run the outer loop from 1 to rows.
for [i = 1; i < = rows; i++]
- For column of rectangle run the inner loop from 1 to columns.
for [j = 1; j < = columns; j++]
- Print star for first or last row or for first or last column, otherwise print blank space.
- After printing all columns of a row, print new line after inner loop.
C++
#include
using
namespace
std;
void
print_rectangle[
int
n,
int
m]
{
int
i, j;
for
[i = 1; i
Javascript
function
print_rectangle[n, m]
{
var
i, j;
for
[i = 1; i
Javascript
Javascript
function
print_square[int n]
{
var
i, j;
for
[i = 1; i