**Solution of good question C operator question**

**Solution section**

**(1)**

output: c

explanation :

0.7f is float constant. Its binary value is written in 32 bit.

0.7 is double constant (default). Its binary value is written in 64 bit.

0.7L is long double constant. Its binary value is written in 80 bit.

binary value of 0.7=(0.1011 0011 0011 0011 0011 0011 0011 0011 0011 0011 0011)

Now, here variable a is a float variable while 0.7 is double constant. So, variable a contains only 32 bit value i.e.

a=0.1011 0011 0011 0011 0011 0011 0011 0011

while

0.7=0.1011 0011 0011 0011 0011 0011 0011 0011 0011 0011 0011....

It is obvious a < 0.7

(2)

Output: 8 24

Explanation:

rule :- ++ is pre increment operator so in any arithmetic operation it first increment the value of variable by one in whole equation then start assigning the end value of variable in the equation . j=++i + ++i + ++i; initial value of i=5 after three times increment i=8 now final value of variable i i.e. 8 will be assigned to each. So j=8+8+8;

j=24;

i=8;

(3)

Output: 5

Explanation:

i++ i.e. when postfix is used with variable in expression then expression is evaluated first with original value then variable is incremented. So i=2+2*1 i=4 now i will be incremented by one so i=4+1=5

(4)

Output:

**0**

**Explanation:**

== is relation operator which will give only two value they are 0: if a==b is false 1: if a==b is true now a=2 b=7 so a==b is false hence b=0

(5)

Output: 10

Explanation:

Output: 10

Explanation:

Comma operator (,) has least precedence and its associative is from left to right so assignment operator (=) has more precedence than comma operator .So = operator will be evaluated first than comma operator x = 10, 20, 30 precedence 1 2 3 first x =10 will be evaluated then control will transfer to 20 then 30.

(6)

Output: false

Explanation:

if(a=0) then a=0 so if(0) means false if(1) means true note : if(n) means true, where n is any number either positive or negative except zero

(7)

Output: 131

Explanation:

015 is octal number its decimal equivalent is =5*8^0+1*8^1 =5+8 =13 0x71 is hexadecimal number (0x is symbol of hexadecimal) its decimal equivalent is =1*16^0+7*16^1 =1+112 =113 so a=13+113+5=131

(8)

Output: 8 4 10

Explanation:

3.14f is float constant. Its size is 4 byte. 3.14 is double constant (default). Its size is 8 byte. 3.14L is long double constant. Its size is 10 byte. sizeof() operator always return the size of data type which is written inside the(). It is keyword.

(9)

Output: 5 20 100

Output: 5 20 100

Explanation:

By default x, y, z are auto type data which stores in stack in memory. Stack is LIFO data structure. So in stack first stores 100 then 20 then 5 and program counter (2 byte) points top element i.e. 5 .Default value of %d in printf is data which is present in stack. So output is revere order of declaration. So output will be 5 20 100.

Note. Initialize variables are more near then uninitialize variable.

(10)

Output: -1

Explanation: Same concept as in question (2) and (13).

(11)

Output: 2

Explanation:! is negation operator it return either integer 0 or 1.

!operand=0 if operand is non zero.

!operand=1 if operand is zero.

So,!5.6=0 ,since 0 is integer number and size of integer data type is two byte.

(12)

Output: Compilation error

Explanation: After using any operator on operand it always return some integer value. (int) i.e. type casting operator is not exception for this. (int) a is converted in any integer value and we cannot assign any constant value to another constant value in c .So

(int)a = 45;

Is equivalent to 3456 = 45. (Here
3456 in any garbage value of int(a)).

(13)

Output: 21

Explanation : rule :- ++ is pre increment operator so in any arithmetic operation it first increment the value of variable by one in whole equation up to break point then start assigning the value of variable in the equation . There are three types of break points in c.

(1) Declaration or initialization statement.

(2) && or operator.

(3) Comma (,) operator.

int a=++i + ++i + ++i;

Here break point is due to declaration and animalization operator .It break after each increment i.e. (initial value of i=5) after first increment value 6 assign to i then next incrementation occur and so on. So, a=6+7+8;

Function
recursion in c

preprocessor

preprocessor directives

#error, #line
preprocessor

preprocessor directives

## 7 comments:

error in 1st program

hi Bandu

Please explain what is error in first program

13th program answer is 24 not 21

a=8+8+8=24

13th pgm answer is 24 not 21

a=8+8+8=24

Answer of question(13) is correct

Program 1:

int a,i=6

a=++i + ++ i + ++i

Program 2:

int i=6

int a= ++i + ++i+ ++i

Both are different.

In program 1: a=24

In Program 2: a=21

Read explanation carefully

Thank u manish......

answer for 13th question is 24 only......

i have executed and checked

Post a Comment