C program expressions Result Result the given expressions wh

C program expressions

Result Result the given expressions, what are the values of a and b la I b and the result of the expression after each statement is a II b a b executed? a b La b a b a & b a && b a &- b

Solution

The program is implemented in C language as specified in the question for C operators

#include <stdio.h>

int main(void)
{
   int a = 6;
   int b = 9;
  
printf(\"\ Bitwise OR of a nd b: %d\",a|b);   //bitwise OR 0110 or 1001 = 1111 =15 in decimal
  
printf(\"\ Logical Or of a and b: %d\",a||b); //logical or a!= 0 ,b !=0 so true or true =true =1
  
printf(\"\ Mod of a and b : %d\",a%b); //Remainder after dividing a by b =6 , 6/9, remainder =6
  
printf(\"\ Shorthand operator of Mod = %d\",a%=b); //shorthand operator for mod
  
printf(\"\ a=b , a= %d\",a=b); //a is assigned the value of b =9
  
printf(\"\ a=b=5 a=%d\",a=b=5); //a=b=5,both a nd b are 5
  
printf(\"\ %d\",a<<=b); //shorthand left shift operator on a=a<<b a=b=5,5<<5 ,5<<101=10100000 =160 in decimal
  
printf(\"\ a==b : %d\",a==b); //relational operator to compare a nd b . They are not equal so results 0
  
printf(\"\ Bitwise a and b: %d\",a&b); // bitwise and 0110 & 1001 =0000 =0 in decimal
  
printf(\"\ Logical a and b :%d\",a&&b); //logical and of a nad b ,both are not equal to 0 so results 1
  
printf(\"\ Shorthand a&=b : %d\",a&=b); //shorthand operator a&=b = a=a&b =0
  
return 0;
}

output:

Success time: 0 memory: 2168 signal:0

C program expressions Result Result the given expressions, what are the values of a and b la I b and the result of the expression after each statement is a II b

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site