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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is New modifiers?

657


int i=10; printf("%d %d %d", i, i=20, i);

1000


Explain setjmp()?

649


What is the difference between formatted&unformatted i/o functions?

608


How can I ensure that integer arithmetic doesnt overflow?

600






Once I have used freopen, how can I get the original stdout (or stdin) back?

618


Write a program to reverse a string.

629


Explain how do I determine whether a character is numeric, alphabetic, and so on?

644


How can I find the modification date and time of a file?

596


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

1872


Explain how do you determine the length of a string value that was stored in a variable?

663


What are header files in c programming?

651


What are disadvantages of C language.

638


How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?

1580


How can I insert or delete a line (or record) in the middle of a file?

566