Thursday, March 3, 2016

C Programming :: Declarations and Initializations

True / False Questions:

1.  A long double can be used if range of a double is not enough to accommodate a real number.
A. TrueB. False
Answer: Option A
Explanation:

True, we can use long double; if double range is not enough.
double = 8 bytes.
long double = 10 bytes.


2.  A float is 4 bytes wide, whereas a double is 8 bytes wide.
A. TrueB. False
Answer: Option A
Explanation:

True,
float = 4 bytes.
double = 8 bytes.


3.  If the definition of the external variable occurs in the source file before its use in a particular function, then there is no need for an extern declaration in the function.
A. TrueB. False
 
   

4.  Size of short integer and long integer can be verified using the sizeof() operator.
A. TrueB. False
Answer: Option A
Explanation:

True, we can find the size of short integer and long integer using the sizeof() operator.
Example:

#include<stdio.h>
int main()
{
    short int i = 10;
    long int j = 10;
    printf("short int is %d bytes.,\nlong int is %d bytes.",
            sizeof(i),sizeof(j));
    return 0;
}
Output:
short int is 2 bytes.
long int is 4 bytes
.

5.  Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C under DOS)
A. TrueB. False
Answer: Option B
Explanation:

False, The range of double is -1.7e+308 to 1.7e+308.

6.  Size of short integer and long integer would vary from one platform to another.
A. TrueB. False
Answer: Option A
Explanation:

True, Depending on the operating system/compiler/system architecture you are working on, the range of data types can vary.


7.  Range of float id -2.25e+308 to 2.25e+308
A. TrueB. False
Answer: Option B
Explanation:

False, The range of float is -3.4e+38 to 3.4e+38.

No comments:

Post a Comment