Question

Write a program that reads a floating­ point number and prints “zero” if the number is...

Write a program that reads a floating­ point number and prints “zero” if the number is zero. Otherwise, print “positive” or “negative”. Add “small” if the absolute value of the number is less than 1, or “large” if it exceeds 1,000,000.

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

// you have not mentioned the language, i have done in c.

//if you require in C++, c#, java, python, r, matlab, octave, scilab etc please comment

#include <stdio.h>

int main()
{
float x,absolute;
printf("Enter the number:");
scanf("%f",&x);
if(x==0)
{printf("Zero\n");absolute=x;}
if(x>0)
{printf("positive\n");absolute=x;}
if(x<0)
{printf("negative\n");absolute=-x;}
if(absolute<1)
printf("small\n");
if(absolute>1000000)
printf("large\n");

return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a program that reads a floating­ point number and prints “zero” if the number is...
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
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