CoolInterview.com - World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS LANGUAGES C DETAILS
    Question :
    There seem to be a few missing operators ...
    Category C Interview Questions
    Rating (0.3) By 9 users
    Added on 11/17/2011
    Views 164
    Rate it!
    Answers:

    There seem to be a few missing operators, like ^^, &&=, and ->=.

    A logical exclusive-or operator (hypothetically ``^^'') would be nice, but it couldn't possibly have short-circuiting behavior analogous to && and || Similarly, it's not clear how short-circuiting would apply to hypothetical assignment operators &&= and ||=. (It's also not clear how often &&= and ||= would actually be needed.)
    Though p = p->next is an extremely common idiom for traversing a linked list, -> is not a binary arithmetic operator. A hypothetical ->= operator therefore wouldn't really fit the pattern of the other assignment operators.
    You can write an exclusive-or macro in several ways:
    #define XOR(a, b) ((a) && !(b) || !(a) && (b)) /* 1 */
    #define XOR(a, b) (!!(a) ^ !!(b)) /* 2 */
    #define XOR(a, b) (!!(a) != !!(b)) /* 3 */
    #define XOR(a, b) (!(a) ^ !(b)) /* 4 */
    #define XOR(a, b) (!(a) != !(b)) /* 5 */
    #define XOR(a, b) ((a) ? !(b) : !!(b)) /* 6 */

    The first is straight from the definition, but is poor because it may evaluate its arguments multiple times The second and third ``normalize'' their operands to strict 0/1 by negating them twice--the second then applies bitwise exclusive or (to the single remaining bit); the third one implements exclusive-or as !=. The fourth and fifth are based on an elementary identity in Boolean algebra, namely that
    _ _ a (+) b = a (+) b

    (where (+) is exclusive-or and an overbar indicates negation). Finally, the sixth one, suggested by Lawrence Kirby and Dan Pop, uses the ?: operator to guarantee a sequence point between the two operands, as for && and ||. (There is still no ``short circuiting'' behavior, though, nor can there be.)



    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    Does C have circular shift operators?
    View Answer
    Is C a great language, or what?
    View Answer
    If the assignment operator were ...
    View Answer
    Does C have an equivalent to Pascals with statement?
    View Answer
    Why doesnt C have nested functions?
    View Answer
    What is assert and when would I use it?
    View Answer
    How can I call FORTRAN?
    View Answer
    What is C Programing language?
    View Answer
    What is hashing in C?
    View Answer
    How can I find the day of the week given the date?
    View Answer
    Was 2000 a leap year?
    View Answer
    Suggesting that there can be 62 seconds in a minute?
    View Answer
    Here is a good puzzle: how do you write a program which produces its own source code as output?
    View Answer
    What is Duffs Device?
    View Answer
    What is C language?
    View Answer
    program at mobile bill calculation based on local std call and sms in c language
    View Answer
    Write a program in c to print
    1
    121
    12321
    1234321
    123454321
    View Answer
    I want to assign values for the charcter which is defined by user ?
    for example:
    enter the grade : S(user defined)
    the credit of s = 10 (should b displayed)

    giv me some idea?
    View Answer
    write a program to print
    * *
    * * * *
    * * * * *
    * * * *
    * *
    View Answer
    Hi All,

    i am currently working on testing in aerospace indursty(system level testing)........and i am planning to change continue my career in C/LINUX domain(testing/development).....can any one tell me skill set required to face "experianced interivew"??....i mean the topics i need to be strong.......thanks in advance
    View Answer


    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL C Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2014 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0.015625 Seconds