closed by
377 views
0 votes
0 votes
closed with the note: undefined Behaviour in C
#include<stdio.h>
int main()
{
	int i = 5;
	int a = ++i + ++i + ++i + ++i;
	printf("%d",a);
	return 0;
}

How is the output 31? and not 30? 

Shouldn’t it be 6+7+8+9?

closed by

Related questions

3 votes
3 votes
5 answers
2
arpit.bagri asked Aug 6, 2023
1,088 views
Why is the output of the below program 36? int main(){ int a = 1; int b = ++a * ++a * ++a; printf("%d", b ); ​​​​ return 0; }
0 votes
0 votes
3 answers
4
lalitver10 asked Oct 23, 2021
700 views
#include <stdio.h>int main(){ int a=20; int *ptr=&a; int x=a; printf ("%p\n",&*ptr); printf ("%p\n",&a); return 0;}Why both printf() line printing the s...