Staircase Hacker Rank Solution In C-language | | Hacker Rank Solutions

Staircase Hacker Rank Solution In C-language | | Hacker Rank Solutions

Question


Observe that its base and height are both equal to , and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces.
Write a program that prints a staircase of size .

Input Format
A single integer, , denoting the size of the staircase.
Output Format
Print a staircase of size  using # symbols and spaces.
Note: The last line must have  spaces in it.


Answer



#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

void staircase(int n) {
    // Complete this function
}

int main() {
     int i,n,j;
    scanf("%d",&n);
    for(i=1;i<=n;++i)
        {
        for(j=1;j<=n;++j)
            {if(j<=(n-i))
            printf(" ");
             else
                 printf("#");
        }
        printf("\n");
    }   
    return 0;
}

Comments :

Post a Comment