manishvaidya
BAN USER- 0of 0 votes
AnswersProgram to create a game of SUDOKU.
- manishvaidya in India| Report Duplicate | Flag | PURGE
Persistent Systems Software Engineer / Developer - 0of 0 votes
Answerswhat is the output
- manishvaidya in United States
main(){
int x=10,y;
y=++x++;
printf("%d%d",x,y);
}| Report Duplicate | Flag | PURGE
C
simple method ,O(n/2)
#include<iostream.h>
#define size 6
void swap(int *x,int *y){
*x=*x+*y;
*y=*x-*y;
*x=*x-*y;
}
void main(){
int i,j=0,k=0,one,zero,arr[]={0,1,1,0,0,1};
cout<<"Orig: ";
for(i=0;i<size;i++)
cout<<arr[i]<<" ";
for(i=0;i<=size/2;i++){
for(;j<size/2;j++)
if(arr[j]==1){
one=j;
break;
}
for(;k<size/2;k++)
if(arr[size-1-k]==0){
zero=size-1-k;
break;
}
swap(&arr[one],&arr[zero]);
}
cout<<"\nRes : ";
for(i=0;i<size;i++)
cout<<arr[i]<<" ";
}
Can you please explain how it works?
- manishvaidya June 18, 2012The answer is b : 10.
Reason : in afunction(), for the pointer 'x' a new space is allocated so it loose the pointer to 'v' and thus the value changed is for new address not for 'v'
RepReneeMartinez, abc at 8x8
As a catering manager with a passion for creating unforgettable culinary experiences, Ihave dedicated my career to the art of ...
I think its coz of precedence. Since ++(post increment) have higher precedence than =(assignment) operator..thus for the first iteration, its picks value 0 increment it to 1 and then assigns to count and it goes on.
- manishvaidya June 23, 2012