Consider that the variables a and b have been declared as integer data type, var
ID: 3766387 • Letter: C
Question
Consider that the variables a and b have been declared as integer data type, variable c has been declared as float data type, variable d has been declared as character data type and a =6,b=-5,c=10 and d=’6’. The following are two separate expressions executed in two different c programs. State whether the final output o the following expressions will be TRUE(1)OR FALSE (0). You must show your workings on how you derive the final answers.
(i)(a==d)||!(b>-2)&&(c!=20)
(ii)(d-5!=1)&&(a==-b+1)&&(c)
Can someone explain in layman’s term how they are computed?
Explanation / Answer
//(a==d)||!(b>-2)&&(c!=20)
//(a==d) will be false since a is not equal to ascii value present in d.
//b>-2 will be false since -5 is less than -2
//c!=20 will be true
// !(b>-2)&&(c!=20) which will be !false && true will be true && true will true
// false or true will be true
//hence above expression will evaluates to true.
//(d-5!=1) this expression will be true since d-5 will not be equal to 1
//a==-b+1 this expression will be true since -(-5)+1 will be 6 and is equal to a hence evaluates to true.
//c is not equal to 0 hence it is true
// true && true && true will be true.
//hence above expression will evaluates to true.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.