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

Where is C used today?
C programming language is still widely used today in various domains. Here are some areas where C remains prevalent: System Programming: C is extensively used for developing operating systems and...
S
0 0
6
Is a default case necessary in a switch statement?
NO, default is optional and you can omit it if there is no use of it.
My
How do you override a defined macro?
We can use the #ifdef and #undef directive to undefine a previously defined macro.
Sharmistha
What are the main characteristics of c programming?
C programming is characterized by several key features that contribute to its popularity and versatility. Here are some of the main characteristics of the C programming language: Procedural Programming: ...
Balendra
0 0
6

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

Ask a Question

Related Lessons

Tress And Its Traversal
Depth First Traversals:(a) Inorder (Left, Root, Right) : 4 2 5 1 3(b) Preorder (Root, Left, Right) : 1 2 4 5 3(c) Postorder (Left, Right, Root) : 4 5 2 3 1 Trees are one of the data structures like...

C Program-Prime Number
/*WAP to print a number entered by the user is prime or not*/ //Header files #include<stdio.h>#include<conio.h> //Main function void main(){ int num,i; //Function for clearing screen clrscr();...
S

Tips of learning Java Language/Other Programming Languages
1.You should know the basic concept: If we talk about programming languages so basic concept are same in all the high level languages. So you should know the basic concept firstly then you can easily understand...
I

ICreative Solution

0 0
0

PRACTISE makes you PERFECT ; ; ; There is no SUBSTITUTE for HARD WORK ;;;;Breathe SUCCESS like OXYGEN
Proper Planning ( reg what portions to be covered today) revising today's class portions & clarifying doubts solving Maths problems regularly ,noting down formulae separately trying to understand...

C Program-The Odd Loop Demo
/* WAP to print square value of the number entered by user using odd loop*/ //Header Files #include<stdio.h>#include<conio.h> //Main Function void main(){ char another='y'; int num,sq; //...
S

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