Simple Program for Increment and Decrement Floating Point Using Pointer in C


Declartion Syntax

(*pt)++; //Pointer Post Increment
++(*pt); //Pointer Pre Increment
(*pt)--; //Pointer Post Decrement
--(*pt); //Pointer Pre Decrement

Simple Program for Increment and Decrement Float Using Pointer

/* Simple Program for Increment and Decrement Floating Point Using Pointer in C*/
/* Print Pointer Address Program,C Pointer Examples */

#include <stdio.h>

int main() {
  float a;
  float *pt;

  printf("Pointer Example Program : Increment and Decrement Float\n");
  a = 10.01;
  pt = &a;

  (*pt)++; //Post float Increment
  printf("\n[a  ]:Increment Value of A = %f", a);

  ++(*pt); //Pre float Increment
  printf("\n[a  ]:Increment Value of A = %f", a);


  (*pt)--; //Post float Decrement
  printf("\n[a  ]:Decrement Value of A = %f", a);

  --(*pt); //Pre float Decrement
  printf("\n[a  ]:Decrement Value of A = %f", a);

  return 0;
}

Sample Output

Pointer Example Program : Increment and Decrement Float

[a  ]:Increment Value of A = 11.010000
[a  ]:Increment Value of A = 12.010000
[a  ]:Decrement Value of A = 11.010000
[a  ]:Decrement Value of A = 10.010000