I've a temperature conversion program as an assignment, which I've completed. The program has many printf
statements in it which print the temperature. Now the negative temperatures are printed the way I want them but the positive temperatures are printed without a leading +
sign.
Now what is the best way to get printf
print a leading +
sign for positive number. All I could think of is to change
printf("Min temp = %d\n",max_temp)
to
if(max_temp > 0)
printf("+");
printf("Min temp = %d\n",max_temp)
But that calls for many changes in program :(
Another option is to write my own print function and put this logic there. What do you suggest ?