retagged by
771 views
1 votes
1 votes
#include <stdio.h>
int main() {
	int a[10];
	int i=0,j=0;
	int res1=0,res2=0;
	int res[10]={0};
	for(i=0;i<10;i++) {
		a[i] = i+1;
		for(j=0;j<10;j++) {
			if(i!=j) res[j] = res[j] ^ a[i]; 
		}
	}
		
	for(i=0;i<10;i++) {
		if(i&1) res2 = res2 ^ a[i];
		else res1 = res1 ^ a[i];
	}
	int sum=0;
	for(i=0;i<10;i++) sum += res1^res2^res[i];
	printf("%d\n",sum);

}

Output of the above program ?

retagged by

Please log in or register to answer this question.

Related questions

4 votes
4 votes
1 answer
1
3 votes
3 votes
2 answers
3
0 votes
0 votes
1 answer
4
TusharKumar asked Dec 22, 2022
524 views
can anyone explain how the for loop works here..?