write a program to check whether in int type number taken as input is a positive, negative or zero
Answers
Hello Friend!
I'm here to help you with a program.
So I am going to write the program you want.
This is a small code so it won't take forever.
I've answered a question similar to this.
So lets get started!
#include <stdio.h>
void main()
{
int num;
printf("Enter any number: \n");
scanf("%d", &num);
if (num > 0)
printf("%d is a positive number \n", num);
else if (num < 0)
printf("%d is a negative number \n", num);
else
printf("0 is neither positive nor negative");
}
JAVA:-
.
import java.util.*;
class Q3
{
static void main()
{
int n;
Scanner sc=new Scanner(System.in);
System.out.println(“Enter a number:”);
n=sc.nextInt();
if(n>0)
System.out.println(“Positive”);
else if(n<0)
System.out.println(“Negative”);
else
System.out.println(“Zero”);
}