hi guys am a computer science undergraduate student from kenya. …
my interest in coding grew suddenly and am studing c …
ive come a cross the use of 4 when using the inter conversion sign eg printf("value= %4d, x) . …my question is whats the importance of 4

need answers asap .thanks

1 Like

@geekf93 The 4 there shows the total number of spaces that the code must print when printing the number. If you represent space as " _ " the printing 42 will print __42 i.e. total of 4 places will be occupied. If you do printf("% .3f " ,val ), it tell the compiler to print 3 places after the decimal.

This is used in formatting of the output to make sure it fits in nicely while making something like a table or grid