BC103 - Editorial

#PROBLEM LINK:

Practice
Contest

Author: Ayush Nagal

#DIFFICULTY:
Easy

#PROBLEM:
Given an integer n, we have to print the given pattern containing n rows and n columns.

#EXPLANATION:
There will be an outer loop for the number of rows. Inside it, there will be two loops: one for spaces and the other one for #.

for(int i=0;i<n;i++)
{
    for(int j=1;j<=n-i-1;j++)
    printf(" ");
    for(int j=0;j<=i;j++)
    printf("#");
    printf("\n");
}

#AUTHOR’S SOLUTION:
Author’s solution can be found here.

3 Likes