Can someone explain the concept of pre and post increment in C?
Please explain ++i and i++ use with example. It confuses me many times, which one increment its value first and when assigned?
- 4212 दृश्य
- 3 उत्तर
3 उत्तर
-
-
- 12 जून
- 0 टिप्पणी
-
-
++i is pre increment operator and i++ is a post increment operator in ++i first i is incremented to i+1 and its value is fetched . in i++ first value of i is fetched then i is incremented to i+1 after execution i.e. incremented value effect can be seen in next statement . let us consider an example where int i=10; int j =i++; //j will contain value of =10 and i will we incremented to 11 vs int j = ++i; // i will be incremented first and then its value will be assigned to j i.e j will contain 11.
-
- 02 अप्रैल
- 0 टिप्पणी
-
- What are storage classes in C language?
- What are jump statements in c language?
- What are preprocessor directives in c language?
- Is C++ better than C sharp? Explain your answer
- Программы и игры для Андроид телефона
- Should I learn C before C++? Explain your answer
- Write a program to store 5 elements in the array P and 3 elements in the array Q.Produce a third array R after joining the array P and Q.Display the resultant array.
- How to dynamically allocate a 2D array in C?
- What site is the best video tutorial website for learning C programming?
- Ищу достойного мужчину!
मॉक परीक्षण अभ्यास के लिए
c programming
Pre and Post increments are operators used in c language.In Pre increment operator(++a),the value of the variable is modified(incremented) first and then its value is assigned to the variable.egbr /int a=2;br /++a;br /printf("%d",a);br /Output:3br /In post increment operator(a++),the value is first assigned to its variable and then modified(increased).br /eg. int a=2;br /a++;br /printf("%d",a);br /Output:2