Use incremental operator to add one to int variable - C Operator

C examples for Operator:Increment Decrement Operator

Description

Use incremental operator to add one to int variable

Demo Code

#include <stdio.h>
#include <stdlib.h>
int main()//w  w  w  .  j  a v  a2 s. com
{
   char weight[4];
   int w;
   printf("Enter your weight:");
   gets_s(weight);
   w=atoi(weight);
   printf("Here is what you weigh now: %i\n",w);
   w++;
   printf("Your weight after the potatoes: %i\n",w);
   w++;
   printf("Here you are after the mutton: %i\n",w);
   w=w+8;
   printf("And your weight after dessert: %i pounds!\n",w);
   printf("Lardo!\n");
   return(0);
}

Result


Related Tutorials