Testing for equality of single or double precision variables

Testing for equality of single or double precision variables may give erroneous results because the supposedly equal variables may vary slightly from each other True False In C++ when comparing char variables the variable values are automatically coerced to values for the comparison. bool int float long Two variables the the same name may be declared in one program provided they are in different blocks of statements. True False

Solution

a)True

Comparing Single and Double precision gives different result as while comparing memory allocated will be compared.That will be 32 bit for Single precision and 64 bit  Double precision

b)bool

In C, a character literal is treated as int type where as in C++, a character literal is treated as char type (sizeof(‘V’)and sizeof(char) are same in C++ but not in C).

In C,comparison gives Int result while in c++ it gives bool result for which we need to include stdbool.h

c)True

C++ /C follows scope rules.If we declare variable within block then its limit will be within that block only

e.g

#include<stdio.h>

int main()

{

int x;

{

int x;

}

}

In above code we have declared 2 vaibles with same name but different block

=======================

comment about work

 Testing for equality of single or double precision variables may give erroneous results because the supposedly equal variables may vary slightly from each othe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site