In each of the following cases what numeric value base 10 is

In each of the following cases, what numeric value (base 10) is stored in the variable x? float x = 1; int x = 2; int x = 1.23; signed char x = -4; char x = \'a\'; int x; float x; char x; unsigned char x = -4;

Solution

a) float x=1

Each case the variable value storage depends on that particular datatype

Here float has 24 bits precision\' so float x=1.0000till 24 bits

B) int x=2 is a decimala value which can be called as a base 10 value

C) int x=1.23 here we are defining x as a int variable but in actual its its a float value so based on that decimal constraint int x=1 or else you need to type cast the variable x as float when ever you are using it any operation

D) signed char x=-4

When you need numeric type of values as characters then you need signed charecters

These characters range from - 127 to +128

Inwhich 1 bit is always stored for the negative sign

E) char x=a

Which stores a variable ofbtype char

F;G;H) for these three

Int x;

Float x;

Char x;

Inthis 3 cases the variable is just declared if it would have initialised then the variable contains that particular initialised value

With out initialization it contains the default value as its valur untill and unless we will assign any value to it

I) unsigned char=-4

Unsigned char stores only positive values if you want to store the value as - 4 then the type should be signed charonly

 In each of the following cases, what numeric value (base 10) is stored in the variable x? float x = 1; int x = 2; int x = 1.23; signed char x = -4; char x = \'

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site