Function drawPrintpattern – CTS PATTERN

You are required to fix all the logical errors in the given code. You can click on Run anytime to check the compilation/execution status of the program. You can use printf to debug your code. The submitted code should be logically/syntactically correct and pass all test cases. Do not write the main() function, as it is not required.

Code Approach: For this question, you will need to correct the given implementation. We do not expect you to modify the approach or incorporate any additional library methods.

The function drawPrintpattern(int num) accepts an integer num. It is supposed to print the pattern as shown in the Example Input/Output section.

Your task is to correct the given code so that it passes all test cases.

Example Input/Output:
Input:
4

Output:
11
1111
111111
11111111

void drawPrintpattern(int num)
{
    int i, j, print=1;
    for (int i=1; i<=num; i++)
    {
        for (j=1; j<=2*i; j++)
        {
            for (j=1; j<=2*i; j++)
            {
                printf("%d",print);
            }
            printf("n");
        }
    }
}
Previous Article

Function root - CTS PATTERN

Next Article

Function checkBirthday - CTS PATTERN

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *