Total members 11895 |It is currently Tue Dec 03, 2024 7:34 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Increment operator in C++
cpp code
#include <stdio.h>

int main()
{
int m = 10;
int n = 5;

m *= n - 3;
printf("%d\n", m);

n = ++m;
printf("%d %d\n", n, m);

n = m++;
printf("%d %d\n", n, m);

n = --m;
printf("%d %d\n", ++n, m);

n = m;
m--;
--n;
printf("%d %d\n", n, m);
}


Code:
++x: Returns the new value of x.

x++: Returns the old value of x.


There is only a difference when the return value is used:
  • x++; and ++x; are the same.
  • Increment operators are similar to Java.
  • Things like x + ++x are not well-defined in C.
  • In the context of C, increments are better able to create bizarre programs.




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : C++ Increment Operators
 How To Increment Date In JSP?     -  
 PHP operators     -  
 shortcut operators     -  
 Using Assignment Operators     -  
 difference between the >> and >>> operators     -  
 Bitwise operators     -  
 using bit-wise operators in c++     -  
 Equality Operators     -  
 Use the boolean compare operators     -  
 Arithmetic Operators in java     -  



Topic Tags

C++ Basics






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com