Problem 08

author
By Supreme2023-02-23
Problem Statement :
Write a C program to find that the accepted number is Negative, or Positive or Zero
Code:

#include <stdio.h>

int main()
{

// 8. Write a C program to find that the accepted number is Negative, or Positive or Zero

printf("\tCheck A Number");
printf("\n===============================");

int num;

printf("\n\nEnter The Value Of A : ");
scanf("%f", &num);

printf("\n_______________________________\n\n");

if (num > 0)
{
printf("A Is positive");
}

else if (num < 0)
{
printf("A is Negative");
}

else if (num == 0)
{
printf("A is Zero");
}
printf("\n_______________________________\n\n");

return 0;
}

Description :
  • This C program checks whether a given number is positive, negative, or zero.
  • It first prints some messages to prompt the user to enter a number. It then takes the input from the user using the scanf function.
  • The program then checks the value of the input number using a series of if-else statements. If the number is greater than zero, it prints "A is positive". If the number is less than zero, it prints "A is negative". If the number is equal to zero, it prints "A is Zero".
  • Finally, the program prints some more messages and returns 0 to indicate successful completion of the program.
Output Image:
Output-image

© Copyright 2022. All right reserved, GTU Coder.