UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is the difference between ++var and var++?

Asked by Last Modified  

Follow 0
Answer

Please enter your answer

Professional Trainer

First one is present increment and second one is the post incremental t of the variable. Both increases value of var to one. The difference between pre and post increment is given in below example. Int a=10. Int b=++a Then a and b both have the value 11. If b=a++ Then a become 11 and b have 10...
read more
First one is present increment and second one is the post incremental t of the variable. Both increases value of var to one. The difference between pre and post increment is given in below example. Int a=10. Int b=++a Then a and b both have the value 11. If b=a++ Then a become 11 and b have 10 old value of a. read less
Comments

Experienced software professional, interested in teaching

first one is pre incrementing, second one is post incrementing. Lets take an example; int a,b=10, c; a=++b; c=b++; The values you get will be a=11; b=12, c=11; In case of pre-incrementation, increment happens first, then assignment. In case of post increment, assignment happens first and then...
read more
first one is pre incrementing, second one is post incrementing. Lets take an example; int a,b=10, c; a=++b; c=b++; The values you get will be a=11; b=12, c=11; In case of pre-incrementation, increment happens first, then assignment. In case of post increment, assignment happens first and then increment; That is why b is incremented twice but a and c got values based on when the increment is performed. read less
Comments

Professional Trainer:: Hadoop Big Data, DevOps, Perl, Python

++var -- is for pre-increment, var++ -- is for post increment you will only see the effect when you are assigning this kind of operation to another variable, say int var=10; int i=0; i=++var; // here value of var(10 is incremented and then assigned to variable i, so i and var will be 10 now) var=10; i=var++;...
read more
++var -- is for pre-increment, var++ -- is for post increment you will only see the effect when you are assigning this kind of operation to another variable, say int var=10; int i=0; i=++var; // here value of var(10 is incremented and then assigned to variable i, so i and var will be 10 now) var=10; i=var++; // here value of var is first assigned to i and then var is incremented so in this case, i=10, var=11; remember to avoid these kind of increment or decrement operators which doing math problems, as debugging will be difficult read less
Comments

Technology expert

++var is pre increment.var++ is post increment.Alone if we see pre/post increment there is no difference.variable will get incremented by 1. We can see the difference between pre/post increment only if we use with assignment operator.++var meaning is first increment then assign.var++ meaning is first...
read more
++var is pre increment.var++ is post increment.Alone if we see pre/post increment there is no difference.variable will get incremented by 1. We can see the difference between pre/post increment only if we use with assignment operator.++var meaning is first increment then assign.var++ meaning is first assign then increment. read less
Comments

Computer & Maths Professor

The ++var is pre-increment whereas var++ is post increment. In case of pre-increment, the variable's value is incremented first and the same incremented value is used in evaluation of the current expression whereas in case of post-increment, the existing value of variable is used in evaluation of the...
read more
The ++var is pre-increment whereas var++ is post increment. In case of pre-increment, the variable's value is incremented first and the same incremented value is used in evaluation of the current expression whereas in case of post-increment, the existing value of variable is used in evaluation of the current expression and than the variable is incremented. read less
Comments

Doing mathematics & computing from IIT Delhi

Let suppose var=3 and we do these two things: 1. a=5; 2. a=5; In first case, first var value will get incremented by 1 and then value 5 is assigned to the array. In second case, first value is assigned to array and then var value will get increment. In first case, value 5 is assigned to a and final...
read more
Let suppose var=3 and we do these two things: 1. a[++var]=5; 2. a[var++]=5; In first case, first var value will get incremented by 1 and then value 5 is assigned to the array. In second case, first value is assigned to array and then var value will get increment. In first case, value 5 is assigned to a[4] and final value of var is 4. In second case value 5 is assigned to a[3] and then value of var is increased to 4. In both case, final value of var is 4 but just the value of a[3] and a[4] are different. read less
Comments

website and mobile application development training, digital marketing training

++var: increase before execution var++: increase after execution
Comments

I am a teacher.

See below example; int var==10; int c,d; c=var++; # value of 'c' here is 10, var is incremented to 1 i.e. 11; var=10; #resetting 'var' value to 10 for your better understanding. d=++var; # value of 'd' here is 11. Even var value also 11. in case of ++var, value of 'var' will be first incremented...
read more
See below example; int var==10; int c,d; c=var++; # value of 'c' here is 10, var is incremented to 1 i.e. 11; var=10; #resetting 'var' value to 10 for your better understanding. d=++var; # value of 'd' here is 11. Even var value also 11. in case of ++var, value of 'var' will be first incremented and then assigned to the lvalue (in above e.g. 'd') in case of var++, first 'var' value will be assigned to the lvalue and then 'var' will be incremented (in above e.g. its 'c'). Kindly let me know if you need still more clarification. read less
Comments

Tuition Teacher

++var is pre- increment operator. For eg-if var=5 then ++5 means 5+1 i.e. 5 will first increase by 1, become 6 and then will do any work. But var++ means post-increment operator. For eg.- if var=5, then 5 will first do any work like entering a loop or addition, multiplication, etc. after this value of...
read more
++var is pre- increment operator. For eg-if var=5 then ++5 means 5+1 i.e. 5 will first increase by 1, become 6 and then will do any work. But var++ means post-increment operator. For eg.- if var=5, then 5 will first do any work like entering a loop or addition, multiplication, etc. after this value of 5 will increase by 1. read less
Comments

Python and Unix Professional(10 years IT Exp)

++var means first value will increase then var will print and in var++ first var value will print then increment take place. main() { i=2; printf("Value of i++ ++i",i++,++i); } output i++ ++i
Comments

View 18 more Answers

Related Questions

What is = and == in C language?
= is assignment operator while ==is comparision operator
Sayed
0 0
6
how the right shift operator works on a numerical value?? eg:- 8>>3=?
first convert numerical value to binary value then arrange into bits and shift 3 bit on right then convert binary value to decimal value.
Abhishek
Why are operating systems written in C? Why aren't other languages used?
C is commonly used for developing operating systems due to its low-level capabilities, efficiency, and direct access to hardware. Its minimalistic design allows for better control over system resources,...
Deepa
0 0
7
What is the best website to learn c language?
In case of problems you will face while making programs, you may take help of google. There may be the situation when you need a helping hand to make clear the basic concepts of programming and internal...
Nom
Why are there so many programming languages if most programmers use C, C++, Java, and PHP?
This question has the same answer as the question"Why there are so many languages?" has... As they were ask meant for different purpose to serve for different platforms... For short: Link it to the languages used
Veerendra
0 0
7

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Set 0 To Kth Bit In A Variable
The following code snippet Set 0 to Kth Bit in an variable #include int UnsetBitValue(int n, int k);int main(){ printf("%d\n\n",UnsetBitValue(255,6)); return 0;}// Set kth bit to zeroint UnsetBitValue(int...

Recursion in C Programming
The process of calling a function by itself is called recursion and the function which calls itself is called recursive function. Syntax of Recursive Function returntype recursive_func () { statements; ...
R

Ravindra Yadav

2 0
0

Bit wise operators in C
Bit Wise Operators Bit Wise operators are manipulates of individual bits with in a word of memory. The bit wise operators can be divided in to three general category. One’s Complement...

Why we need to learn Programming languages?
Language is medium for communication. If two parties like to communicate or exchange the thoughts they must know a language. Language should be understandable by both the Parties. For example A wants to...

C Program-Upper Case Demo
/*WAP to print the character entered by user in upper case*/ //Header files #include<stdio.h>#include<conio.h> //Main function void main(){ char ch; //Function for clearing screen clrscr(); ...

Recommended Articles

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Applications engineering is a hot trend in the current IT market.  An applications engineer is responsible for designing and application of technology products relating to various aspects of computing. To accomplish this, he/she has to work collaboratively with the company’s manufacturing, marketing, sales, and customer...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more