what is the diffrence between ++x , x++ pleaaaaase ???

Answer Posted / dallasnorth40

++ before the variable increments the variable before the
value is taken/used.
++ after the variable takes/uses the value, then increments.

Given:
int x = 5;
int y = 0;

y = x++;
This will leave y = 5 and x = 6.


y = ++x;
This will leave y = 6 and x = 6.

Is This Answer Correct ?    27 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?

2565


output for printf("printf");

1985


Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37

2051


write a program that reads a series of strings and prints only those strings begging with letter "b"

2674


write a program using virtual function to find the transposing of a square matrix?

2845






write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.

3959


Code for Two Classes for Doing Gzip in Memory?

2814


Write a simple encryption program using string function which apply the substitution method.

5539


find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L

2010


Code for Easily Using Hash Table?

2391


create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file

2220


can you please write a program for deadlock that can detect deadlock and to prevent deadlock.

2748


how to diplay a external image of output on winxp by using c & c++,

2938


What output does the following code generate? Why? What output does it generate if you make A::Foo() a pure virtual function? class A { A() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; class B : public A { B() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; int main(int, char**) { A objectA; B objectB; return 0; }

644


What output does this program generate as shown? Why? class A { A() { cout << "A::A()" << endl; } ~A() { cout << "A::~A()" << endl; throw "A::exception"; } }; class B { B() { cout << "B::B()" << endl; throw "B::exception"; } ~B() { cout << "B::~B()"; } }; int main(int, char**) { try { cout << "Entering try...catch block" << endl; A objectA; B objectB; cout << "Exiting try...catch block" << endl; } catch (char* ex) { cout << ex << endl; } return 0; }

580