Question

Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write...

Please help me with this program. Using C++ (printf & scanf) statements.

Thank you.

ASSIGNMENT:

Write a program to ask the user for a number that includes a decimal point. Then display the integer part of the number (the part of the number to the left of the decimal point) and the decimal part of the number (the part of the number to the right of the decimal point, including the decimal point

Follow the 3 steps in the Information Processing Cycle - Input, Processing, and Output. Do not format the output to any number of decimal places, and don't forget the ending punctuation.

Have a blank line at the end of your program to separate the last line of output from your program from the "Press any key to continue . . .", and do this for all programs that you write.

Example Run #1:
(bold type is what is entered by the user)

Enter a number that includes a decimal point: 123.456
The integer part of 123.456000 is 123.
The decimal part of 123.456000 is 0.456000.

The example run shows EXACTLY how your program input and output will look.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

int main() {
    double num;
    printf("Enter a number that includes a decimal point: ");
    scanf("%lf", &num);
    printf("The integer part of %.6lf is %d.\n", num, (int)num);
    printf("The decimal part of %.6lf is %.6lf.\n", num, num-((int)num));
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C language using printf and scanf statements: Write a program to display a histogram based...

    In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...

  • In C using (printf and scanf) Write a program to ask the user for the weight...

    In C using (printf and scanf) Write a program to ask the user for the weight of a package, and display the shipping charges for the package. If the weight of the package is less than or equal to 0 pounds, inform the user and exit the program. The shipping charges are: Weight of Package Shipping Charge 2 pounds or less $1.25 Over 2 pounds but not more than 6 pounds $2.50 Over 6 pounds but not more than 10...

  • USING C# LANGUAGE WE USE SCANF AND PRINTF PLEASE USE THAT IN THE ANSWER WE DONT...

    USING C# LANGUAGE WE USE SCANF AND PRINTF PLEASE USE THAT IN THE ANSWER WE DONT USE CONSOLEWRITE OR READ Write a program that takes in a number from the user. Then it prints a statement telling the user if the number is even or odd. If the number is odd, it counts down from the number to 0 and prints the countdown on the screen, each number on a new line. If the number is even, it counts down...

  • This program should be run on Visual Studio. Please use printf and scanf as input and...

    This program should be run on Visual Studio. Please use printf and scanf as input and output. Thank you 6.11 Lab Exercise Ch.6a: Functions: String analyzer Create and debug this program in Visual Studio. Upload your Source.cpp file for testing (1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: ics Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have...

  • Hospital Charges ASSIGNMENT: Write a program to calculate and display the amount of the charges for...

    Hospital Charges ASSIGNMENT: Write a program to calculate and display the amount of the charges for a hospital stay. Create a global constant for the daily fee of a hospital room ($350.00/day). Ask the user for: The number of days spent in the hospital The amount of the medication charges The amount of the surgical charges The amount of the lab fees The amount of the physical rehabilitation charges Then, using functions, calculate the stay charges (number of days *...

  • Just do program 6 using c++ which are printf and scanf. Please don’t use cout and...

    Just do program 6 using c++ which are printf and scanf. Please don’t use cout and cin. Program 4: A slot machine has three windows. A random fruit is picked for each window from cherry apple, lemon, and orange. If all three windows match, the user wins 8 times the bet amount. If the first two windows only are cherries, the user wins 3 times the bet amount. If the first window is a cherry and the second window is...

  • Using C Programming: (use printf, scanf) 18. Tic-Tac-Toc Game Write a program that allows two players...

    Using C Programming: (use printf, scanf) 18. Tic-Tac-Toc Game Write a program that allows two players to play a game of tic-tac-toc. Use a two- dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that Displays the contents of the board array Allows player 1 to select a location on the board for an X. The program should...

  • In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a...

    In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter an integer value. Your program will then display that integer back to the user. Your program should include a function called getInteger that requests an integer value from the user and returns that value back to the caller. Your main () function will call the function getInteger and will then display the value returned by that function....

  • Please use Python Exercise 1 Create a program named sentinel_loop using break. This program should implement...

    Please use Python Exercise 1 Create a program named sentinel_loop using break. This program should implement functionality that is the same as the Part 1 tutorial example, except for the following differences: • • This program should count even and odd integers. This program should report counts of even and odd integers. Remember that even integers can be identified using the test condition: value % 2 == 0 Remember to test your code for appropriate behavior when the user signals...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT