Input Format
The first line contains a single integer denoting .
Constraints
Output Format
If , then print the lowercase English word corresponding to the number (e.g., one for two for , etc.); otherwise, print Greater than 9 instead.

hackerrank conditional statements in c programming problem solution

Conditional Statements in C problem solution | HackerRank

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
    
    int n;
    scanf("%d", &n);
    if(n == 1) {
        printf("one");
    }
    else if(n == 2) {
        printf("two");
    }
    else if(n == 3) {
        printf("three");
    }
    else if(n == 4) {
        printf("four");
    }
    else if(n == 5) {
        printf("five");
    }
    else if(n == 6) {
        printf("six");
    }
    else if(n == 7) {
        printf("seven");
    }
    else if(n == 8) {
        printf("eight");
    }
    else if(n == 9) {
        printf("nine");
    }
    else {
        printf("Greater than 9");
    }
    
    return 0;
}

Second Solution

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

    int n;
    char* represent[10] = {"Greater than 9", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};

    scanf("%d", &n);

    if(n > 9) {
        printf("%s", represent[0]);
    }
    else {
        printf("%s", represent[n]);
    }

    return 0;
}