Computer Science, asked by shweta6474, 6 months ago

Accept a number from keyboard and check whether it is a positive number, negative number or a zero.
Print suitable message.

please tell me the correct answer


I will mark as brainlist

who tell right answer ​

Answers

Answered by gopikab2004
1

1st method

#include <stdio.h>

int main() {

double num;

printf("Enter a number: ");

scanf("%lf", &num);

if (num <= 0.0) {

if (num == 0.0)

printf("You entered 0.");

else

printf("You entered a negative number.");

} else

printf("You entered a positive number.");

return 0;

}

OUT PUT :

Enter a number: 12.3

You entered a positive number.

2nd method :

#include <stdio.h>

int main() {

double num;

printf("Enter a number: ");

scanf("%lf", &num);

if (num < 0.0)

printf("You entered a negative number.");

else if (num > 0.0)

printf("You entered a positive number.");

else

printf("You entered 0.");

return 0;

}

OUT PUT :

Enter a number: 0

Enter a number: 0You entered 0.

Hope this helps you ☺️

Answered by adbadwaik
1

see

and mark as brainlist ok

to the question which you asked after this

Attachments:
Similar questions