Sort by

recency

|

1623 Discussions

|

  • + 0 comments

    // start c++

    include

    using namespace std; int main() { int a, b; //a> a >> b;//a

            cout << names[i - 1] << "\n";
        }
    }
    if (a>9)
    {
        for (int j = 10; j <= b; j++)
        {
            if (j % 2 == 0)
            {
                cout << "even\n";
            }
            else
            {
                cout << "odd\n";
            }
        }
    
    }
    
    if (a<9&&b>9)
    {
        for (int i = a; i <= 9; i++)//a=5,b=15;
        {
    
            cout << names[i - 1] << "\n";
        }
        for (int j = 10; j <= b; j++)
        {
            if (j % 2 == 0)
            {
                cout << "even\n";
            }
            else
            {
                cout << "odd\n";
            }
        }
    
    }
    
    return 0;
    

    }

  • + 0 comments

    int main() { int a, b; cin >> a >> b; for (int i=a; i <=b; i++){ switch (i) { case 1: cout << "one" << endl; break; case 2: cout << "two"<< endl; break; case 3: cout << "three"<< endl; break; case 4: cout << "four"<< endl; break; case 5: cout << "five"<< endl; break; case 6: cout << "six"<< endl; break; case 7: cout << "seven"<< endl; break; case 8: cout << "eight"<< endl; break; case 9: cout << "nine"<< endl; break; default: if (i>9 && i%2==0){ cout << "even"<< endl;} else { cout << "odd"<< endl; } } } return 0; }

  • + 0 comments

    int main() { int a,b; cin>>a>>b;

    string nums[] = {"one","two","three","four","five","six","seven","eight","nine"};
    
    for(int i=a;i<=b;i++){
        if (i >= 1 && i <= 9){
             cout<<nums[i-1]<<endl;
        }
        else if(i %2 ==0){
            cout<<"even"<<endl;
        }else{
            cout<<"odd"<<endl;
        }
    
    }
    
    
    return 0;
    

    }


  • + 0 comments
    int main() {
        int a, b;
        cin >> a >> b;
    		
        string numbers[] = {"one", "two", "three", "four", "five", 
                            "six", "seven", "eight", "nine"};
    
        for (int i = a; i <= b; i++) {
            if (i >= 1 && i <= 9) {
                cout << numbers[i - 1] << endl;
            } else if (i % 2 == 0) {
                cout << "even" << endl;
            } else {
                cout << "odd" << endl;
            }
        }
        return 0;
    }
    
  • + 0 comments

    My C++ code 😎😁

    void switchFunction(int n){
        switch(n){
            case 1 :
               cout <<"one"<<endl;
               break;
            case 2 : 
               cout <<"two"<<endl;
               break;
            case 3 : 
               cout <<"three"<<endl;
               break;
            case 4 :
               cout <<"four"<<endl;
               break;
            case 5 :
               cout <<"five"<<endl;
               break;
            case 6 :
               cout <<"six"<<endl;
               break;
            case 7 :
               cout <<"seven"<<endl;
               break;
            case 8 : 
               cout <<"eight"<<endl;
               break;
            case 9 :
               cout <<"nine"<<endl;
               break;
            default :
               cout <<"Greater than 9"<<endl;
               break;
        }
    }
    
    int main() {
        // Complete the code.
        int a(0),b(0);
        cin >>a>>b;
        
        for(a;a<=b;a++){
            if(a>=1 and a<=9){
                switchFunction(a);
            }else{
                if(a %2 == 0){
                    cout <<"even"<<endl;
                }
                else{
                    cout <<"odd"<<endl;
                }
            }
            
        }
        return 0;
    }