Computer Science, asked by kumarpratyaksh450, 7 months ago

Input a number and tell if it is +ve or -ve or neutral​

Answers

Answered by imtiyazallam
0

Answer:

Python

a = int(input("Enter a number: "))

if(a == 0):

print("The number is neutral.")

elif(a < 0):

print("The number is negetive.")

else:

print("The number is positive.")

Ruby

print("Enter a number: ")

a = gets.to_i

if(a == 0)

puts("The number is neutral.")

elsif(a < 0)

puts("The number is negetive.")

else

puts("The number is positive.")

Java

import java.util.*;

public class Numbers {

public static void main(String args[]) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter a number: ");

int a = sc.nextInt();

if(a == 0)

System.out.println("The number is neutral.");

else if(a < 0)

System.out.println("The number is negetive.");

else

System.out.println("The number is positive.");

}

}

C++

#include<iostream>

using namespace std;

int main() {

cout << ("Enter a number: ");

int a;

cin >> a;

if(a == 0)

cout << ("The number is neutral.") << endl;

else if(a < 0)

cout << ("The number is negetive.") << endl;

else

cout << ("The number is positive.") << endl;

}

Answered by anindyaadhikari13
1

\star\:\:\:\sf\large\underline\blue{Question:-}

  • Write a program to input a number and tell if it is positive negative or neutral.

\star\:\:\:\sf\large\underline\blue{Source\:Code:-}

In Java

import java.util.*;

class Program

{

public static void main(String s[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter a number: ");

int n=sc.nextInt();

String s="";

if(n>0)

s="Positive";

else if(n<0)

s="Negative";

else

s="Neutral";

System.out.println("Number is "+s);

}

}

Similar questions