LIVE Course for free

Rated by 1 million+ students
Get app now
0 votes
99 views
in Information Technology by (24.2k points)
closed by
Expression C = i++ causes
1. value of i to be assigned to C, and then I to be incremented by 1
2. I to be incremented by 1, and then value of i to be assigned to C 
3. value of i to be assigned to C
4. i to be incremented by 1

1 Answer

0 votes
by (24.2k points)
selected by
 
Best answer
Correct Answer - Option 1 : value of i to be assigned to C, and then I to be incremented by 1

Concept:

Meaning of i++:

First, we read the i than after reading the value of i we are going to increment i this is nothing but post-increment.

Meaning of ++i: 

First, we increment i than we read the value of I, this is nothing but pre-increment:

Examine code:

int main( )
{
int i = 10;
int C = i++;   // assign i to C therefore C = 10 after assigning increment i by 1
printf("i = %d, C =  %d", i, C);
return 0;
}

Output:

i = 11, C =  10

Therefore value of i to be assigned to C, and then I to be incremented by 1

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...