For Loop in C || Hacker Rank

Question 7 || Hacker Rank

For Loop in C || Hacker Rank

For Loop in C || Hacker Rank



Objective

In this test, you will gain proficiency with the use of the for circle, which is a programming language explanation which permits code to be executed until a terminal condition is met. They might in fact rehash always assuming that the terminal condition is rarely met.

The punctuation for the for circle is:

for ( <expression_1> ; <expression_2> ; <expression_3> )
    <statement>
expression_1 is utilized for intializing factors which are for the most part utilized for controlling the ending banner for the circle.
expression_2 is utilized to check for the ending condition. On the off chance that this assesses to misleading, the circle is ended.
expression_3 is by and large used to refresh the banners/factors.
The accompanying circle introduces to 0, tests that is under 10, and additions at each cycle. It will execute multiple times.

for(int I = 0; I < 10; i++) {
    ...
}

Task

For every whole number in the span (given as information) :

In the event that ,, print the English portrayal of it in lowercase. That is "one" for , "two" for ,, etc.
Else on the off chance that and it is a considerably number, print "even".
Else in the event that and it is an odd number, print "odd".
Input Arrangement

The primary line contains a whole number, .
The seond line contains a number, .

Imperatives

Yield Arrangement

Print the proper English representation,even, or odd, in view of the circumstances depicted in the 'task' area.

Note:

Test Information

8
11
Test Result

eight
nine
indeed
odd


#include <stdio.h>
int main() 
{
    int a,b,n;
    scanf("%d",&a);
    scanf("%d",&b);
    for(n = a;n<=b;n++)
    {
       if(n == 1
        printf("one\n");
    else if(n == 2
        printf("two\n");
    else if(n == 3
        printf("three\n");
    else if(n == 4
        printf("four\n");
    else if(n == 5
        printf("five\n");
    else if(n == 6
        printf("six\n");
    else if(n == 7
        printf("seven\n");
    else if(n == 8
        printf("eight\n");
    else if(n == 9
        printf("nine\n");
    else {
        if(n %2 ==0)
            printf("even\n");
        else
           printf("odd\n");
    }}
    return 0;
}


Output


For Loop in C || Hacker Rank


Post a Comment

0 Comments