Sort by

recency

|

1636 Discussions

|

  • + 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.

  • + 0 comments
    #include <iostream>
    using namespace std;
    
    int main() {
        int a, b;
        cin >> a;
        cin >> b;
        string num[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "even", "odd"};
        int i =0;  
        for (i=a; i<=b; i++){
            if (i<=9)         
                cout <<num[i]<< endl;
            else if ( (i>9) && (i%2)==0)
                cout << "even" << endl;
            else if ( (i>9) && (i%2)==1)
                cout << "odd" << endl;
        } 
        return 0;
    }
    
  • + 0 comments
    #include<string>
    #include<iostream>
    #include<cstdio>
    using namespace std;
    
    int main(){
        // Complete the code.
        int num1,num2;
        cin>>num1>>num2;
        string arr[]={"one","two","three","four","five","six","seven","eight","nine"};
        for(int n=num1;n<=num2;n++){
            if(n<=9 && n>=1){
                cout<<arr[n-1]<<endl;
            }
            else if(n>9 && n%2==0){
                cout<<"even"<<endl;
            }
            else{
                cout<<"odd"<<endl;
            }
        }
        return 0;
    }
    
  • + 0 comments

    I think this is the approach which i think make sense as a begineer....

    well i may be wrong xd;)

    !!!

    int main() {

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

    }