Question: Write a C program that prompts the user to type a number. Have your program accept the number as an integer and immediately display the
Write a C program that prompts the user to type a number. Have your program accept the number as an integer and immediately display the integer using a printf() function call. Run your program three times. The first time you run the program, enter a valid integer number; the second time, enter a double-precision number; and the third time, enter a character. Using the output display, see what number your program actually accepted from the data you entered.
Repeat the exercise above, but have your program declare the variable used to store the number as a single-precision variable. Run the program four times. The first time, enter an integer; the second time, enter a decimal number with fewer than six decimal places; the third time, enter a number with more than six decimal places; and the fourth time, enter a character. Using the output display, keep track of what number your program actually accepted from the data you typed in. What happened, if anything, and why?
Repeat the exercise above, but have your program declare the variable used to store the number as a double-precision variable. Run the program four times. The first time, enter an integer; the second time, enter a decimal number with fewer than six decimal places; the third time, enter a number with more than six decimal places; and the fourth time, enter a character. Using the output display, keep track of what number your program actually accepted from the data you typed in. What happened, if anything, and why?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
