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

In Java programming, what are the differences between the functions of 'int' and 'int []' when working with an array?
The may appear as part of the type at the beginning of the declaration, or as part of the declarator for a particular variable but But int a keeps type information together and is more verbose so I prefer it.
Kalpana
0 0
5
How can a program be made to print the line number where an error occurs?
int print_document(char* doc_name, int destination) { switch (destination) { case TO_FILE: print_to_file(doc_name); break; case TO_SCREEN: ...
Rituparna
0 0
7
Is the C language required to learn Java?
No, learning C is not a strict requirement for learning Java. Java and C are distinct programming languages with different syntax, features, and purposes. While having a background in C can provide a solid...
Akhilesh
0 0
7
Which is the best C language IDE/compiler for Windows?
Let us now check out some of the famous and best-working IDEs available. Visual Studio Code. Visual Studio Code is one of the most popular IDEs and is open-source software developed by Microsoft....
Deepashri
0 0
5

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

Ask a Question

Related Lessons

C Program-Error Handling
//Header files #include<stdio.h>#include<conio.h>#include<stdlib.h> //Main function void main(){ int dividend=10; int divisor=0; int quotient; //Function for clearing screen clrscr(); ...

Facts about C language
C programming language was developed in 1972 by Dennis Ritchie at AT&T Bell Labs. It was developed to overcome the problems of languages such as B, BPCL. It was developed to write the Unix operating...

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...

4 Things Every Tech Startup Needs to Know About The Coaching Industry
Knowledge on any subject is widely available to those who wish to learn. However, just gathering knowledge from other people doesn’t guarantee results in business. Results come from applying what...

Necessity of Theory and Practical in Computer Science.
Upon studying a subject both theory and practical are important. Usually many schools concentrate more on theory and the marks not on the practical. Other and opposite kind of people prefer practical...

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