Find the value of the expression : 5 && c !=8 || !c

0 Chris Daniel · May 23, 2015
For c = 0. Is the value true or not true ?

Post a Reply

Replies

Oldest  Newest  Rating
0 Superman HC · May 24, 2015
for c = 0

=> 5 && 0 != 8 || ! 0                      // NOT operator (opposite bit)
=> 5 && 0 != 8 || 1                       //  Not equal to (if not equal then true)
=> 5 && 1 || 1                              // Logical AND (if both operands are non-zero, then true) 
=> 1 || 1                                       // Logical OR  (if any of the operand is non-zero, then true)
=> 1 
(True)
0 c student · May 24, 2015
#include <stdio.h>
#include <assert.h>

#define TRUE 1

int main(void) {
    int c = 0;
    assert (((5 && c !=8) || !c) == TRUE);
    assert ((5 && (c !=8 || !c)) == TRUE);
    return 0;
}

http://ideone.com/lqDyWf
0 Chris Daniel · May 25, 2015
Thanks Ravi 
  • 1

C

107,042 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator