Questions tagged [post-increment]

For issues relating to defining or performing post increment operations.

Post-increment operators increase the value of their operand by 1 (or another specified amount), but the value of the operand in the expression is the operand's original value prior to the increment operation.

561 questions
-5
votes
3 answers

How did this output come from this program?

Hello pro coders of stackoverflow community, I'm still a beginner and I need help understanding the problem below: int main() { int x=4,y=0; while(x>=0) { if(x==y) break; else …
-5
votes
5 answers

C# While (i++ ...) when increments?

Why does While loop post-increments (or post-decrements) a variable right after examination of the condition and not after the whole loop? As in: int x = 0; while (x++ < 5) Console.WriteLine(x); The output is: 1 2 3 4 5, when I believe it should…
Matt
  • 31
  • 1
  • 4
-5
votes
1 answer

unary increment doesn't work?

public class Temp { public static void main(String[] args) { for (int i = 0; i < 10;){ i = i++; System.out.println("Hello world"); } } } why i does not get increment as we are incrementing it still it does not get…
-5
votes
1 answer

How to construct a loop that produces a temp conversion chart

From input of a starting and ending fahrenheit temperature and a temperature increment, I want to construct a loop that calculates fahrenheit and temperature using the standard formulas and increments the conversion till it gets to the final…
-5
votes
1 answer

postincrement operation in same statement

the question is to understand how the standards define or allow to handle these situations and what would be behaviour in this particular case wherein the variable undergoing post/pre increment is used in same statement as that of expression, when…
Himanshu Sourav
  • 700
  • 1
  • 10
  • 35
-5
votes
4 answers

why the result of '*s-*t" in the while loop is "67"?

please i can't understand the while loop , why the loop show A two time and not one char *s,*t; s="ABC"; t="AA"; do {printf("A");} while(*s++==*t++); printf("%d %d",*s-*t);
-5
votes
2 answers

C Pointer manipulation in switch statement

Hi folks i tried to program a simple switch statement and stuck uppon this problem. I cant figure out why this code works correctly, i guess it is because the precedence of the operators ** and ++. If this is the case ill be happy if someone can…
igal
  • 3
  • 2
-5
votes
3 answers

Why i'm getting Segmentation fault (core dumped) in the following code?

In this code making use of a-- and b++ shows Segmentation fault, but if am giving --a and ++b its working, why?! add(a,b) { if (a==0) return b; else return add(a--,b++); //why this line didn't work??! }
-5
votes
3 answers

Unexpected Output involving array values with post and pre-increment

Shouldn't the output of following program be - 2 3 20 instead it is showing 3 2 15 Can anyone explain the reason behind this? #include main() { int a[5] = {5,1,15,20,25}; int i,j,m; i = ++a[1]; j = a[1]++; m =…
raesrem
  • 55
  • 4
-5
votes
2 answers

what is the value of a after { a=5; a=a++; Syso(a);}

After running this program, I am getting value of 'a' as 5 instead of 6.Why? public class Test { public static void main(String args[]) { int a=5; a=a++; //post increment operator System. out. println…
JavaSat
  • 34
  • 2
  • 8
-5
votes
1 answer

how does one determine the behaviour of post increment values when passed to macros

#define man(x,y)((x)>(y))?(x):(y); int main() { int i=10,j,k; j=5; k=0; k=man(++i,j++); printf("%d %d %d",i,j,k); return 0; } The output is: 12 5 12 Can anyone make it clear as to how the value of i,k is 12 and not 11.
-6
votes
2 answers

Why does variable i not change after i=i++?

I didn't understand the below question in LinkedIn's Java Assessment Test: for(int k =0; k<10; k=k++) { k+=1; System.out.println("Hello world."); } Why does this code print 10 times "Hello world."? I know k++ means, first do job…
Kuvalya
  • 1,094
  • 1
  • 15
  • 26
-6
votes
2 answers

C: What is the output of the following code? And please explain

int a = 5; if(a==a++){ printf("true 1"); } if(a==++a){ printf("true 2"); } When I run this code, it prints "true 2". I do not understand how. Please help. Also, how is logical equivalence computed in precedence with increment operators?
-6
votes
2 answers

Why NaN is returned by a post-increment operator?

When the following line of code is executed in node.js console the result is: var string = 'abc'; string++; // NaN string; // NaN I thought that it should work like this: var string = 'abc'; string++; // 'abc'; string; // NaN My…
Alexander
  • 257
  • 1
  • 3
  • 11
-6
votes
2 answers

Increment in both side in C

What is the meaning of the following line in C. What is the order of execute it? float *x,*y; *x++=*y++ Can any one explain how this evaluated?
Afnan
  • 35
  • 1
  • 1
  • 5
1 2 3
37
38