For Loop in C | HackerRank - Samsus Salehin Sabbir

Header Ads

For Loop in C | HackerRank

Problem Link : For Loop in C

Solution :
      Develop by
 Samsus Salehin Sabbir 

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <stdlib.h>

  5. int main() {

  6.     int a, b;
  7.     char* represent[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
  8.     scanf("%d\n%d", &a, &b);
  9.     for(int i = a; i <= b; i++) { 
  10.         
  11.         if(i > 9) {
  12.             if(i % 2 == 0)
  13.                 printf("even\n");
  14.             else printf("odd\n");
  15.         }
  16.         else {
  17.             printf("%s\n", represent[i]);
  18.         }
  19.     }
  20.     return 0;
  21. }

No comments

Powered by Blogger.