What is the output for the increment operator's placement (postfix versus prefix). - C Language Basics

C examples for Language Basics:printf

Introduction

When the increment operator is placed to the left of the variable, it will increment the variable's value by 1 first, before it's used in the expression.

Demo Code

#include <stdio.h> 
int main() //from w w  w .ja v  a 2s.  co m
{ 
   int x = 0; 
   int y = 0; 

   printf("\nThe value of y is %d\n", y++); 
   printf("\nThe value of x is %d\n", ++x); 
   
   return 0;
}

Result


Related Tutorials