Study of console i/o - 4 Study of field width to justify output.

#include <stdio.h>

int main(void)
{
int num, x;
printf("\nEnter a number : ");
scanf("%d", &num);

for(x = 1 ; x <= 10 ; x++)
{
//printf("\n%d X %d = %d", num, x, num * x);
//printf("\n%5d X %5d = %5d", num, x, num * x); // default: right justify
printf("\n%-5d X %-5d = %-5d", num, x, num * x); // left justify
}

return 0;
}

No comments:

Post a Comment

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin