1
23
456
7890
How can i get an output like this in C compiler by not just usind printf():?
Is this what you're looking for?
#include %26lt;stdio.h%26gt;
int main()
{
puts( "1" );
puts( "23" );
puts( "456" );
puts( "7890" );
return 0;
}
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
int i,j,k=1;
clrscr();
for(j=1;j%26lt;=4;j++) //print exactly 4 rows
{
printf("\n"); //moves to next line
for(i=1;i%26lt;=j;i++) //print exactly the same times no.of rows
{
if(k%26lt;10)
{
printf("%d",k);
}
else
{
printf("%d",a%10) ; //if k %26gt;10 then print remainder of k/10
}
k=k+1;
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment