5,479 views
1 votes
1 votes
{

double b =5 & 3 && 4 || 6 | 6 ;

printf("%lf",b);

}

a.2.000000

b.1.0

c.1.000000

d.compilation error

1 Answer

2 votes
2 votes

double b =5 & 3 && 4 || 6 | 6 Breaking the expression

Precedence higher to lower --> & , | , && , ||

Evaluating expression steps:

5 & 3 && 4 || 6 | 6

1 && 4 || 6 | 6

1 && 4 || 6

1 || 6

1

Now 1 is typecasted to double Hence answer is C

Answer is not B because double type in C gives answer upto 6 correct digit after decimal point.

Related questions

870
views
1 answers
2 votes
Jason asked Mar 1, 2018
870 views
#include <stdio.h> #include <iostream> using namespace std; int main() { printf("Hello World"); int a = 10, b = 20, c= 30, d = 40; int e = ++a || ++b || ++c && ++d; // ... b = 20 c = 31 d = 41.but the output is a = 11 b = 20 c = 30 d = 40
824
views
0 answers
4 votes
Shubhanshu asked Oct 15, 2017
824 views
Consider the following Program:-#include <stdio.h> int main() { short a = 1, b = 1, c = 1, d; d = ((a++ || b++ && c++) || 1); printf("a ... greater than that of OR, which means && should be executed before ||, but it is not happening. Why??
4.7k
views
1 answers
2 votes
saipriyab asked Nov 28, 2017
4,735 views
The output of the following programmain ( ){int a = 1, b = 2, c = 3;printf (“%d”, a+ = (a+ = 3, 5, a));}
642
views
1 answers
1 votes