Printing numbers with and without the + flag : printf sign character « printf scanf « C Tutorial






#include <stdio.h>

int main()
{ 
   printf( "%d\n%d\n", 786, -786 );
   printf( "%+d\n%+d\n", 786, -786 );

   return 0;

}
786
-786
+786
-786








4.3.printf sign character
4.3.1.+ Indicates that i number is printed using a sign character (+ or -).
4.3.2.' ': Indicates a space for positive values so that positive values and negative values are aligned
4.3.3.Printing a space before signed values not preceded by + or -
4.3.4.Printing numbers with and without the + flag