• edited by
4,849 views
2 2 votes

#include <stdio.h>

int arr[] = { 10, 20, 30, 40, 50 };

static int count ;

inc() {

return ++count;

}

int main()

{

arr[count++]=inc();

printf("%d ", arr[count]);

printf("%d ", arr[0]);

}

https://ideone.com/5LOuqj 

 

3 Answers

0 0 votes

the answer is 30,2 here

 

0 0 votes
undefined behaviour  Sequence Point Problem.

arr[count++]=inc();

arr[count++]=++count;
Position:
Show:

Related questions

0 0 votes
1 1 answer
833
833 views
Gurdeep Saini asked Jan 28, 2019
833 views
when i printing x it is giving 0 but when comparing x with 5 ,it executing else part ,means condition fail ,why ??#include <stdio.h int main(void) { int x; if(x=(printf("...
0 0 votes
0 0 answers
805
805 views
utkarshkosta asked Dec 22, 2018
805 views
#include<stdio.h int main() { char A[5][7][6]; char *p[5][7][6]; printf(“%d\t”,(unsigned)(A+1)-(unsigned)A); printf(“%d”,(unsigned)(p+1)-(unsigned)p); } OPTIONS:42 ...
1 1 vote
2 answers 2 answers
848
848 views
rahul sharma 5 asked Dec 14, 2016
848 views
For n=2 the P is coming as 3,but none of the option is satisfying?
0 0 votes
0 0 answers
512
512 views
Mrityudoot asked Feb 26, 2024
512 views
Trying out a code to get all the possible marks that can be obtained in a GATE paper.Assumptions taken : 1) All questions are MCQs (all questions have a chance of negativ...