Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is the value of y in the following code?
x=7;y=0;
if(x=6)
y=7;
else
y=1;

Answers were Sorted based on User's Feedback



What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / mahendra giri

y will be 7 because in the if condition we have assigned
value 6 on x not ==,so ans of
y =7

Is This Answer Correct ?    40 Yes 2 No

What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / deepa

y = 7

Is This Answer Correct ?    22 Yes 3 No

What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / piyush

its looks logically incorrect,but in c anc c++ if any such
incident occurs like if(x=6), this condition is always
treated as true

will give a warning ,but will execute this as considering
the if condition as true

ANSWER to this question is y=7

Is This Answer Correct ?    15 Yes 0 No

What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / gg

Ans: 7

Coz all non-zero statements are treated as true.
code can be written as..

if(TRUE)/*x=6 is a non-zero*/
Y=7;
else
y=1;

Note: To compare,have to use '==' operator.'=' is an
assignment operator.

Is This Answer Correct ?    12 Yes 0 No

What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / shruti

y = 7..

Is This Answer Correct ?    5 Yes 0 No

What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / balaji jayakumar

y=7 because if condition doesnt fail... so the immediate
statement after if will be executed and 7 gets printed. It
is quite certain only if "if" fails else will be be opted
for. so y=7... no error statements will occur.. i have tried
it in c.

Is This Answer Correct ?    3 Yes 0 No

What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / priya

Logically it is wrong ,because relational operator(==) is
used to check the condition/expression
if(x==6) then the result of y is 1

Is This Answer Correct ?    3 Yes 0 No

What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / vijay r15

In c non zero values
in if statement r
considered to be true

here if(i=6)
so it makes if(6)
hence its true

op is 7

if 1ly execute false
for if(0)

got it
r
mail to
raj.Vijay55@gmail.Com

Is This Answer Correct ?    2 Yes 1 No

What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / suchita

this is logically wrong bcoz we use relational opr in
conditional statements. and thats why he displays last
statements.

Is This Answer Correct ?    4 Yes 8 No

What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;..

Answer / bhagya

1

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More C Interview Questions

Where are c variables stored in memory?

0 Answers  


What is the use of void pointer and null pointer in c language?

0 Answers  


Why does not use getgh(); and <conio.h> in c language.

3 Answers   Elofic,


What is variable declaration and definition in c?

0 Answers  


Explain modulus operator.

0 Answers  


typedef struct { int i:8; char c:9; float f:20; }st_temp; int getdata(st_temp *stptr) { stptr->i = 99; return stptr->i; } main() { st_temp local; int i; local.c = 'v'; local.i = 9; local.f = 23.65; printf(" %d %c %f",local.i,local.c,local.f); i = getdata(&local); printf("\n %d",i); getch(); } why there there is an error during compiling the above program?

1 Answers  


How to write in a function declaration and in function call in which the function has 'n' number of varible or arguments?

2 Answers  


Is c an object oriented programming language?

1 Answers  


Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d

1 Answers   TCS,


Describe how arrays can be passed to a user defined function

0 Answers  


If the static variable is declared as global, will it be same as extern?

1 Answers   Samsung,


explain what is a newline escape sequence?

0 Answers  


Categories