79416825

Date: 2025-02-06 05:14:44
Score: 0.5
Natty:
Report link
#include <stdio.h>

int main(void)
{
     
     int i = 15;
     printf("(int) i++: %d, i: %d\n", i++, i);
    
     float j = 15.0;
     printf("(float) j++: %g, j: %g\n", j++, j);
    
     double k = 15;
     printf("(double) k++: %g, k: %g\n", k++, k);
return 0;
}

--------------------------
Output: 
(int) i++: 15, i: 16
(float) j++: 15, j: 15
(double) k++: 15, k: 16
--------------------------
Note the difference between the usage 
of  %f and %g
As a good practice, use increment/decrement 
operator on int type data


As per my understanding it isn't as good programming style to use increment/decrement operator on values of float data type, given the nature of the operator that clearly increases or decreases the value by 1 based on the operator used.
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Shagun Shukla