HackerRank C- Conditional Statements in C




Given a positive integer denoting , do the following:

If 1<=n<=9, then print the lowercase English word corresponding to the number (e.g., one for 1 , two for 2 , etc.).
otherwise, print Greater than 9 instead



  1. #include <assert.h>
  2. #include <limits.h>
  3. #include <math.h>
  4. #include <stdbool.h>
  5. #include <stddef.h>
  6. #include <stdint.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. int main()
  11. {
  12. int n;
  13. scanf("%d",&n);
  14. if(n==1)
  15. {
  16. printf("one");
  17. }
  18. if(n==2)
  19. {
  20. printf("two");
  21. }
  22. if(n==3)
  23. {
  24. printf("three");
  25. }
  26. if(n==4)
  27. {
  28. printf("four");
  29. }
  30. if(n==5)
  31. {
  32. printf("five");
  33. }
  34. if(n==6)
  35. {
  36. printf("six");
  37. }
  38. if(n==7)
  39. {
  40. printf("seven");
  41. }
  42. if(n==8)
  43. {
  44. printf("eight");
  45. }
  46. if(n==9)
  47. {
  48. printf("nine");
  49. }
  50. else if(n>9)
  51. {
  52. printf("Greater than 9");
  53. }
  54. }




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube