Question

Write a function pounds2kilos that returns the metric (kilo) equivalent of a weight given in pounds...

Write a function pounds2kilos that returns the metric (kilo) equivalent of a weight given in pounds (all values should be floats). Use this function in a program that keeps asking the user for a weight in pounds and reports the equivalent value in kilos. If the user enters something other than a number, the program should exit.

Note: the scanf function will return the number of values successfully scanned from the line (which may be 0, if the line had no scannable values).

THE PROGRAMMING LANGUAGE IS C.

the function should keep asking the user for new input WITHOUT printing anything.

Homework Answers

Answer #1

C PROGRAM ===>

#include <stdio.h>
#include <stdlib.h>

float pounds2kilos()
{
float pound ,kilo;

  
// while loop runs until input is not a number
while((scanf("%f",&pound)!=0))
{
kilo = 0.45359237*pound;
}
return 0;
}
int main()
{
pounds2kilos(); // call function
return 0;
}

OUTPUT SCREENSHOT ===>

Know the answer?
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
Similar Questions
Write the functions which are called in the main function given. YOU MAY ASSUME THAT THE...
Write the functions which are called in the main function given. YOU MAY ASSUME THAT THE USER ENTERS A VALID INTEGER. printDouble should accept one value and should print the value of that number times 2. printEndMessage should not accept any values and should print a message indicating that the program has finished. def main(): num1 = int(input("Please enter your number ")) printDouble(num1) printEndMessage() main()
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT