Computer Science, asked by ayush7294, 1 year ago

write a program to input a number to find whether it is positive or negative


Anonymous: which language?
Anonymous: ok
ayush7294: ok

Answers

Answered by Anonymous
2
hey mate

here is your answer

//a program in Java to find
//whether a number is
//positive or negative

import.Java.util.*;
class positive_negative
{
public static void main (string args [])
{
Scanner sc=new Scanner (System.in);
system.out.println ("enter a number");
int n=sc.nextInt();
if(n>0)
system.out.println ("positive number");
else
system.out.println ("negative number");
}
}

assumption:all the inputs are of int data type

ayush7294: in c++ also
Similar questions