Members BookmarksPolls Fresher Jobs Strange Photos Academic Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

Advertisements


website counter



C Operators-Increment Operator


Posted Date: 12 Jun 2008    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology

Posted By: Girish Patil       Member Level: Diamond
Rating:     Points: 4



INCREMENT OPERATOR
Introduction
You can increment or decrement the value of variable using the increment or decrement operator. These operators can be applied only to variables and they can be applied using prefix form or postfix form.

Program
#include

main( )
{
int I,j,k;
i = 3;
j =4;
k = i++ + --j;
printf("i = %d, j = %d, k = %d",i,j,k);
}

Input
i =3, j = 4.

Output
i = 4, j = 3, k = 6.

Explanation
When the prefix form is used, the value of the variable is incremented/decremented first and then applied. In the postfix form, the value is applied and only after the assignment operator is done is the value incremented or decremented.

Suppose you write

i = 3;
j =4;
k = i++ + -j;

you will get the value of k as 6, i as 4 and j as 3. The order of evaluation is as follows:

i gets the value 3.

j is decremented to 3.

k gets the value 3 + 3.

i is incremented.

Suppose you write

i = 5;
i = i++ * i++

Then you will get the value of i as 27. This is because first the value 5 is used as to make i = 25 and then i is incremented twice. The increment and decrement operators have higher priority than the arithmetic operators




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: C Operators-Ternary Operator
Previous Resource: C Operators-Comma Operator
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources


Contact Us    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.