Question

Write one complete C program that asks the user for a floating point number and displays...

Write one complete C program that asks the user for a floating point number and displays the absolute value of the number with two decimals of accuracy. You are not allowed to use the abs or fabs functions.

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

#include<stdio.h>

int main() {
  
float x;
  
// taking user input
printf("Enter a floating point number: ");
scanf("%f", &x);
  
if(x < 0) // making it absolute number
x = x * -1;
  
printf("Number is %.2f", x); // printing output
}

Please up vote

Add a comment
Know the answer?
Add Answer to:
Write one complete C program that asks the user for a floating point number 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
  • Write a program that asks the user to enter number, and displays all the numbers that...

    Write a program that asks the user to enter number, and displays all the numbers that are multiples of 2 and 5 smaller than or equal to the number entered by the user. Hint: A number n is a multiple of 2 if the remainder of the division of n by 2 is equal to zero. Your program should have an output similar to the following: Please enter a number: 50 The multiples of 2 and 5 less than or...

  • Write a C++ program that asks the user for an exam score. The program displays on...

    Write a C++ program that asks the user for an exam score. The program displays on the screen the appropriate later grade as per the schema below: a. A: [90-100] b. B: [80:89] c. C: [70:79] d. D: [60:69] e. F: otherwise

  • Write a C# Windows Form program that asks the user to enter a name (in a TextBox) and displays the following message (in...

    Write a C# Windows Form program that asks the user to enter a name (in a TextBox) and displays the following message (in a Label): Hello, yourName! https://youtu.be/6nNiMeWK37w can be helpful... (unfortunately the sound did not record) You will use Visual studio to complete this task. The final deliverable to be uploaded to the assignment dropbox is the entire visual studio solution folder that has been compressed or zipped.

  • In Python 3, Write a program that reads a set of floating-point values. Ask the user...

    In Python 3, Write a program that reads a set of floating-point values. Ask the user to enter the values, then print: The number of values entered. The smallest of the values The largest of the values. The average of the values. The range, that is the difference between the smallest and largest values. If no values were entered, the program should display “No values were entered” The program execution should look like (note: the bold values are sample user...

  • Write a C++ program that will have a predefined array and then asks the user to...

    Write a C++ program that will have a predefined array and then asks the user to enter an integer value call it number . Then write the following functions to display:  All values larger than number

  • 2) Write a program in C/C++ that asks the user to enter a number then the...

    2) Write a program in C/C++ that asks the user to enter a number then the user's input value is passed to a function which increments the number by 10 and returns the result of the incrementation. Write the program to accomplish the increment using three (3) different techniques. To test each technique separately, the user should enter a different number for each of the three (3) techniques. Make sure that you compile and execute your program. Finally, provide screenshots...

  • Problem 16. Write a program to prompt the user for a floating point number x and...

    Problem 16. Write a program to prompt the user for a floating point number x and compute the following formula: Problem 18. Write a program fragment that uses nested for loops to produce the following output, making sure that the user input is between 3 and 42.

  • Write a console-based program ( C # ) that asks a user to enter a number...

    Write a console-based program ( C # ) that asks a user to enter a number between 1 and 10. Check if the number is between the range and if not ask the user to enter again or quit. Store the values entered in an array. Write two methods. Method1 called displayByVal should have a parameter defined where you pass the value of an array element into the method and display it. Method2 called displayByRef should have a parameter defined...

  • 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 program that displays as many integers in the Fibonacci sequence as the user wishes...

    Write a program that displays as many integers in the Fibonacci sequence as the user wishes to see. The user must be prompted for: • the starting two integers in the sequence • the number of integers to display in the series The resulting series must be printed to the screen. You must use some form of repetition to accomplish this (a loop). You must also use functions (in addition to main) C PROGRAMMING

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