Conditional Statements in C || Hacker Rank

 Question 6 || Hacker Rank

Conditional Statements in C || Hacker Rank

Conditional Statements in C || Hacker Rank


Objective

In the event that and else are two of the most often utilized conditionals in C/C++, and they empower you to execute zero or one restrictive explanation among numerous ward restrictive articulations. We use them in the accompanying ways:


on the off chance that: This executes the collection of organized code beginning with if assesses to valid.


if (condition) {

    statement1;

    ...

}

if - else: This executes the assortment of organized code beginning with if assesses to valid, or it executes the assemblage of code beginning with if assesses to bogus. Note that only one of the organized code segments will at any point be executed.


in the event that (condition) {

    statement1;

    ...

}

else {

    statement2;

    ...

}

in the event that - else if - else: In this construction, subordinate proclamations are binded together and the for every assertion is possibly checked assuming all earlier circumstances in the chain are assessed to misleading. Once an assesses to valid, the organized code related with that assertion is executed and the program then, at that point, jumps to the furthest limit of the chain of explanations and executes. In the event that each in the chain assesses to misleading, the assemblage of organized code in the else block toward the end is executed.


if(first condition) {

    ...

}

else if(second condition) {

    ...

}

.

.

.

else if((n-1)'th condition) {

    ....

}

else {

    ...

}


Task

Given a positive number meaning , do the accompanying:


In the event that , print the lowercase English word comparing to the number (e.g., one for , two for , and so on.).

If , print More noteworthy than 9.


Input Arrangement

The main line contains a solitary whole number, .

i.e., 1 is less than equal to n maore than equals to 10 to power 9


Imperatives


Yield Configuration

On the off chance that ,, print the lowercase English word relating to the number (e.g., one for , two for , and so on); in any case, print More prominent than 9 all things being equal.


Test Information

5

Test Result

five

Test Information #01

8

Test Result #01

eight

Test Information #02

44

Test Result #02

More noteworthy than 9



#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;

}


Output

Conditional Statements in C || Hacker Rank



Post a Comment

0 Comments