Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question #2 Is what I need help on. This is C Programming. The printer their sim

ID: 3665878 • Letter: Q

Question

Question #2 Is what I need help on. This is C Programming.

The printer their simples fiers, which, in etter in 8d or 8f. Review Questions You'll find answers to the review questions in Append A, "Answers to the 1. Which data type would you use for each of the following kinds of da than one type could be a. The population of East Simpleton b. The cost of a movie on DVD c. The most common letter in this chapter d. The number of times that the letter occurs in this chapter 2. Why would you use a type long variable instead of type int? 3. What portable types might you use to get a 32-bit signed integer, a rationale be for each choice? 4. Identify the type and meaning, if any, of each of the following com a. Ab b. 1066 c, 99.44

Explanation / Answer

Why would you use a type long variable instead of type int?

The main reason behind using long type variable instead of int type variable is to store large numbers.

The size of int type variable is 16 bit. Which means it can generate 2^16 numbers = 65536

The range of numbers would be 32767 to 32767 (If we use signed integer)

The range of numbers would be 0 to 65535 (If we use unsigned integer)

So, if you use a signed integer you'd only be able to work with the number from range 32767 to 32767

And if you use an unsigned integer you'd only be able to work with the number from range 0 to 65535

The problem is, If you define a signed or unsigned integer and your program tries to store a value beyond the respective range of the integer, it’ll generate a wrong value. If you define a variable with initial value which is beyond the range, compiler will generate a warning while compiling the program.

*Please note that if you don't mention signed or unsigned for an integer variable, the variable would be signed integer by default. E.G: int i    //This integer i is signed integer by default

To avoid this problem you can use long as data type of a variable. The long type variable is 32 bits in size. Which means it can generate 2^32 numbers = 4294967296 numbers

The range of numbers would be 2147483647, +2147483647 (If we use signed integer)

The range of numbers would be 0 to 4294967296 (If we use unsigned integer)

So, if you use long data type you can use store larger numbers than int data types.

*Please note that, above size of int and size of long data type is truly depends upon hardware and software architecture. This may vary. So you may able to find that the size of int data type is 32 bit or 64 bit in some machines. In that case size of long data type will also increase proportionally.

For example:

In machines having x86 architecture the size of int data type is 32 bit. So the range for int we can use in this machine is 2147483647, +2147483647

If we store the maximum number of above range in an integer which is +2147483647, the below program works fine.

#include<stdio.h>

main()

{

int i;

i=2147483647;

printf("%d",i);

}

But if we increase the number by one the below program will generate an error while compiling. Because the number is out of the range of int now.

#include<stdio.h>

main()

{

int i;

i=2147483648;

printf("%d",i);

}