24 Computer -- Programming Concepts and Logics

ask mattrab Visit www.askmattrab.com for more academic resources.

C program to check whether the input number is positive, negative or zero

// To check whether the input number is positive, negative or zero


#include <stdio.h> 

#include<conio.h>           

int main() 

    int A;       // Variable A is declared as integer

  

    printf("Enter the number A: ");         

    scanf("%d", &A);         // Here, & provides the link to the input and gets stored in A.                                                                                                              %d  symbolizes the integer value.

  

          if (A > 0) 

             printf("%d is positive.", A); 

          else if (A < 0) 

            printf("%d is negative.", A); 

         else if (A == 0) 

           printf("%d is zero.", A); 

   getch();                // ( In this case) It is used to pause the screen to view the output. 

Discussions

More notes on Programming Concepts and Logics

Close Open App