Skip to main content

Posts

Showing posts with the label positive or zero.

ads1

Python Condition , 3.Write a Python program to check whether a number is negative, positive or zero.

3. Write a Python program to check whether a number is negative, positive or zero.   Solution :- no1 = int(input("Enter the number :- ")) if (no1 > 0):     print("The number is Positive",no1) elif (no1 <0):     print("The number is Negative",no1) else :     print("The number is Zero",no1) Output :-    

15. Write a C program to check whether a number is negative, positive or zero.

  15. Write a C program to check whether a number is negative, positive or zero. Solution :-  #include<stdio.h> #include<conio.h> void main() {     clrscr();     int a;     printf("Enter the number :-");     scanf("%d",&a);     if (a>0)     {         printf("%d The number is Positive....");     }     else if(a<0)     {         printf("%d The number is Negative......");     }     else     {         printf("%d The number is Zero......") ;     } getch(); } Output :-     

3. Write a Java program to check whether a number is negative, positive or zero.

  3. Write a Java program to check whether a number is negative, positive or zero. Solution :-  Static class posnegzero {     public static void main(String args[])     {     int no1=-0;         if(no1 >0)         {             System.out.println("The number is Positive:- "+no1);         }         else if(no1 < 0)         {             System.out.println("The number is Negative :- "+no1);         }     else     {         System.out.println("The number is Zero :- "+no1);     }     } }  Output :-  Dynamic Solution import java.util.*; class posnegzero    {     public static void main(String args[])     {         int no1;           Scanner out = new Scanner(System.in);         System.out.println("Enter the first number :- ");         no1 = out.nextInt();         if(no1 > 0)         {             System.out.println("The number is Positive :- "+no1);         }         else if(no1 < 0)         {             System.out.printl

ads2