Question

Write a C function called display_dollar which takes a floating point number as input, and displays...

Write a C function called display_dollar which takes a floating point number as input, and displays this is a dollar value to the screen. This means that it should have a ‘$’ in front of it, and be displayed to exactly two decimal places in non-scientific form. Your function should not put spaces or newlines before or after the output?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I am here attaching the code in the code snippet with the output image.

#include<stdio.h> 
float display_dollar(float num);
int main() 
{ 
     float num;
    printf("enter the number");
    scanf("%f",&num);
   
    display_dollar(num);
}
float display_dollar(float num){
         
        
        printf("$%0.2lf", num); 
}

Hope this helps You

THANK YOU

Add a comment
Know the answer?
Add Answer to:
Write a C function called display_dollar which takes a floating point number as input, and displays...
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
  • USING C# 1. Write a program that takes outputs a string, an integer and a floating-point number s...

    USING C# 1. Write a program that takes outputs a string, an integer and a floating-point number separated by commas. Sample output: Bob Marley, 20, 5.2 2. 2. Write a program that asks the user for a string of letters of any size (no spaces), and finally a special character (values 33 to 47 in the Ascii table, or ‘!’ to ‘/’). Generate a random number of any size, integer or floating point, and combine those three pieces of information...

  • Write a computer program that takes as input a floating point number x in the interval...

    Write a computer program that takes as input a floating point number x in the interval [−π, π], and an integer n in the range 1, 2, ..., 10, and calculates sin(x) using the Taylor series definition within an accuracy of 10−n . Indicate your programming language of choice, and include a screen shot of your test cases.

  • C++ ONLY Write a function calculator that takes two floating numbers and one operator and prints...

    C++ ONLY Write a function calculator that takes two floating numbers and one operator and prints out the answer based on arithmetic. Assume that there are no overflow, underflow and division by zero cases. Your function should be named calculator Your function takes three input parameter: two double numbers and one char operator Your function does not return anything Your function prints answer in the format specified below Your function should set precision point to 2 Note: You must use...

  • Write a function in the C++called summary that takes as its parameters an input and output...

    Write a function in the C++called summary that takes as its parameters an input and output file. The function should read two integers find the sum of even numbers, the sum of odd numbers, and the cumulative product between two values lower and upper. The function should return the sum of even, odd, ad cumulative product between the lower and upper values. Please write program in C++.

  • Write a matlab function called strip Write a function called strip which takes in a single...

    Write a matlab function called strip Write a function called strip which takes in a single string s, and returns a version of s with all the spaces removed. The format of the output is specified in the following examples >> strip ('This is a test') This is a test >> strip ('Another test') Another test

  • using C++ Write a full program (starting from #include) that takes as input the number of...

    using C++ Write a full program (starting from #include) that takes as input the number of seconds after midnight. It then displays the time in hours:minutes:seconds format. Assume the time is displayed in military time, e.g. 06:06:06 or 23:05:57. Note the placement of the zeros for numbers less than 10, which your program should properly display. Your program should show output as in the example below. Enter number of seconds after midnight: 3601

  • Write a program that takes an operation (+, -, /, or *) and two floating-point numbers,...

    Write a program that takes an operation (+, -, /, or *) and two floating-point numbers, and outputs the result of applying that operation to the two numbers. For example, if the input is: + 100 3.14 the output should be 100 + 3.14 = 103.14 Likewise, if the input is * 4 5 the output should be 4 * 5 = 20 You may assume the input is well-formed; that is, the first string is one of the four...

  • C++ Program with 2 functions 1. Hamming Functions Tester Write a function that displays a menu...

    C++ Program with 2 functions 1. Hamming Functions Tester Write a function that displays a menu to test the functions from 2 - 4. You must call the functions from 2 - 4 and cannot reimplement their functionality in this function. The menu is displayed as follows: 1) Enter a 4-bit message to encode into a 7-bit Hamming message. 2) Enter a 7-bit Hamming message to transmit through a noisy channel. 3) Enter a 7-bit Hamming message to receive and...

  • Write a C program named space_to_line.c that features a while loop that continuously reads input from...

    Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...

  • Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as...

    Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as output, c, returns the number of zeros at the beginning of v (number of zero elements before any non-zero element). For example, for input (-5, 5, 11] the output would be 0. If the input is [0, 0, 3, 0, 0, 0], the output would be 2. If the input is [0, 0, 0, 0, 7, 4) the output would be 4. 5) Write...

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