Sort by

recency

|

1639 Discussions

|

  • + 0 comments

    int main() { int a , b; cin>>a; cin>>b; // Complete the code. for(int i=a;i<=b;i++ ,a++){ if(i==1){ cout<<"one\n"; } else if (i==2){ cout<<"two\n"; } else if (i==3){ cout<<"three\n"; } else if (i==4){ cout<<"four\n"; } else if (i==5){ cout<<"five\n"; } else if (i==6){ cout<<"six\n"; } else if (i==7){ cout<<"seven\n"; } else if (i==8){ cout<<"eight\n"; } else if (i==9){ cout<<"nine\n"; } else if(i%2==0){ cout<<"even\n"; } else{ cout<<"odd\n"; } }

    return 0;
    

    }

  • + 0 comments

    include

    using namespace std;

    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 % 2 == 0) 
                    cout << "even" << endl;
                else 
                    cout << "odd" << endl;
        }
    }
    
    return 0;
    

    }

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

    include

    include

    using namespace std;

    int main() { int a,b; cin>>a; cin>>b; string s[20]={"one","two","three","four","five","six","seven","eight","nine"};

    for(int i=a;i<=b;i++)
    {
        if(i>=1 && i<=9)
        {
            cout<<s[i-1]<<endl;
        }
        else if(i>9 && i%2==0)
        {
            cout<<"even"<<endl;
        }else{
            cout<<"odd"<<endl;
        }
    }
    
    
    return 0;
    

    }

  • + 0 comments

    I'm working on a website and need help adding a C++ loop to my code. The loop should generate a series of numbers based on specific start, stop, and step values, and display the results in real-time on the website. Any suggestions or tips from experienced developers would be greatly appreciated.