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 meant by "bit masking"?
Mask means to block in bit masking, blocking can be done by bit by bit e.g. 0101 1000 OR -------------- 1101
Kiran
0 0
6
Why is the C program giving the wrong output?
Hi Chandra, Please remember that the program will not give wrong output. The output might be wrong only in the case where there has been incorrect logic used or different output is expected. What is the...
Chandra
0 0
5
How are portions of a program disabled in demo versions?
By inserting comments in the program Single line comment denoted by // Multi line comment denoted by /* */
Akhilesh
0 0
5
How would you round off a value from 1.66 to 2.0?
using ceil function. i.e. ceil(1.66)
Dhanya
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

Why do pointers have a datatype?
Before we start with pointers you must know what is a variable and a datatype. int a; This is the basic line in every program in 'C' . It means that we are asking the compiler to give us 2 bytes of space...

C Program-Vowels and Consonants
/*WAP to print the character entered by user is a vowel or consonant*/ //Header files #include<stdio.h>#include<conio.h> //Main functionvoid main(){ char c; //Function for clearing screen...

Variables
Variables in C Language:A variable is a name that may be used to store a data value. Unlike constant, variables are changeable, we can change value of a variable during execution of a program. A programmer...

C-Program Swapping Contents Of Variables Using Function [Call By Reference Method]
//Header Files #include#include // User defined functions swap with 2 pointer variables passed as an argument list void swap(int*i,int*j){ // Local variable temp int temp; // swapping contents using...

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

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