Pattern doubt not getting output in patter form

Why i am not getting my output uin form of patter
#include<stdio.h>
int main()
{
int n=4,val=1,row=1,col;
while(row<=n)
{
col=1;
while(col<=row)
{
printf("%d\n",val);
val++;
col++;
}
row++;
}
printf("\n");
return 0;
}

Hello @farid.chorshanbiev,

The reason for getting wrong pattern:
printf("%d \n",val);
Explanation:
You are ending line after printing each character.
Solution:
while(row<=n)
{
col=1;
while(col<=row)
{
printf("%d ",val);
val++;
col++;
}
row++;
printf("\n");
}

Hope, this would help.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.