We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>intmain(){intn;scanf("%d",&n);// Complete the code to print the pattern.intp=n;intdec,inc;for(inti=0;i<(2*n)-1;i++){if(i+1>n)dec=(n-1)-((i+1)%n);elsedec=i;inc=dec;for(intj=0;j<(2*n)-1;j++){if((2*n)-1-j<=inc){p++;}printf("%d ",p);if(dec>0){dec--;p--;}}printf("\n");}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Printing Pattern Using Loops
You are viewing a single comment's thread. Return to all comments →