Advertisement
BearWulf

Untitled

Feb 15th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. /* Getting a number and checking for the sign */
  3. int CheckSign()
  4. {
  5. int x;
  6. scanf(“%d” , &x);
  7. if (x>=0) // x is positive.
  8. return 1;
  9. else // x is negative.
  10. return 0;
  11. }
  12. /* Print a positive number message */
  13. void PrintPos()
  14. {
  15. printf(“It’s a Positive Number.\n”);
  16. }
  17. /* Print a negative number message */
  18. void PrintNeg()
  19. {
  20. printf(”It’s a negative number.\n”);
  21. }
  22. int main()
  23. {
  24. int a;
  25. printf(“Please enter a positive number: \n”);
  26. a = CheckSign();
  27. if (a==1)
  28. {
  29. PrintPos();
  30. printf(”\n Great !\n”);
  31. }
  32. else
  33. {
  34. PrintNeg();
  35. printf(“\n Try next time.\n”);
  36. }
  37. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement