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.
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",£)!=0))
{
kilo = 0.45359237*pound;
}
return 0;
}
int main()
{
pounds2kilos(); // call function
return 0;
}
OUTPUT SCREENSHOT ===>
Get Answers For Free
Most questions answered within 1 hours.