In this post students will be able to learn how to find whether a given number is zero, positive or negative with the help of algorithm, flowchart and C Programming language.


Write an algorithm, flowchart and program to find whether a given number is zero, positive or negative.

Algorithm:
  1. Start
  2. Initialize a variable num to store the input number.
  3. Read the value of num from the user.
  4. If num is equal to zero, print “The number is zero.” and stop.
  5. If num is greater than zero, print “The number is positive.” and stop.
  6. If num is less than zero, print “The number is negative.” and stop.
  7. Stop.
FLOWCHART:
Program:
#include<stdio.h>
int main() {
int num;
printf("Enter a number:");
scanf("%d",& num);
if (num==0){
printf("the number is zero");
}
else if(num>0){
printf("the number is positive");
}
else{
printf("the number is negative");
}
return 0;
}



Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *