C
Programming and Technical
Category
void fun()
{
// what should be the logic here to print x=20 instead of x=10 in the main function?
}
void main()
{
int x=20;
fun();
x=10;
printf("%d",x);
getch();
}
Read Solution (Total 4)
-
- as fun() doesn't have anything to display ,X will be still 20 untill it is initialized by 10. now 10 is stored in the variable x. Hence answer is 10
- 8 years agoHelpfull: Yes(1) No(4)
- we can use constant keyword for x=20
- 8 years agoHelpfull: Yes(0) No(1)
- the answer is 10 because the value of 20 is replaced by 10.
- 7 years agoHelpfull: Yes(0) No(1)
- the answer is 10.
- 7 years agoHelpfull: Yes(0) No(1)
C Other Question
void main(){
int a=1;
void xyz(int , int);
xyz(++a,a++);
xyz(a++,++a);
printf("%d",a);
}
void xyz(int x, inty){
printf("%d%d",x,y);
}
Find the Output.
int main(){
char a=250;
int expr;
expr= a+ !a + ~a + ++a;
printf("%d",expr);
return 0;
}
Options:249,250,0,-6