I have posted my code below which is in fact giving the same output as expected.Please help me with this problem as I am constantly experiencing this type of problems in other platforms also such as HackerRank and HackerEarth etc...I think this type of problems arises as the tester instead of Evaluating the Final output evaluates the Code thereby limiting the scope of Creativity.I am currently a beginner in coding any help will be highly appreciated.
#include <stdio.h>int main()
{
int num;int i=1,j,x;
scanf("%d", &num);
x=num-1;
printf("Input number is %d.\n", num);
for(i=1;i<=num;i++)
{
if((i==1)||i==num)
{
for(j=1;j<=num;j++)
{
printf("*");
}
printf("\n");
x--;
}
else
{
for(j=1;j<=x;j++)
printf(" ");
printf("*");
printf("\n");
x--;
}
}
}
Aucun commentaire:
Enregistrer un commentaire