0% found this document useful (0 votes)
28 views

10 Printpattern

The document describes a method printpattern(int) that prints a pattern of increasing numbers based on the input integer. It provides test cases and sample output for inputs of 4 and 1. It also includes the C++ code for the printpattern method and a main method calling it with an input of 5.

Uploaded by

Tharun konda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

10 Printpattern

The document describes a method printpattern(int) that prints a pattern of increasing numbers based on the input integer. It provides test cases and sample output for inputs of 4 and 1. It also includes the C++ code for the printpattern method and a main method calling it with an input of 5.

Uploaded by

Tharun konda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

/*

The method printpattern(int) of class drawpattern is


expected to expected to print the first n (n > 0)
Lines of the pattern
TESTCASES
TestCase 1
Input:
4
Expected Return value:
11
1111
111111
11111111
TestCase 2:
Input:
1
Expected Return Value:
11

public class drawpattern


{
public static void printpattern(int n)
{
int i,,j,print = 1;
for(i=i;i<=n;i++)
for(j=1;j<=2 * i;j++)
System.out.print( (print ));
System.out.println();
}
}*/

void printpattern(int n)
{
int i,j,print = 1;
for(i=1;i<=n;i++)
{
for(j=1;j<=2 * i;j++)
printf("%d", print);
printf("\n");
}

int main()
{
printpattern(5);

return 0;
}

//Errors
// for(i=i;i<=n;i++) to for(i=1;i<=n;i++, printf("\n"))

You might also like