Sort by

recency

|

1634 Discussions

|

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

    }

  • + 0 comments

    That sounds great! But in my opinion, C Loop challenges like off-by-one errors, optimizing nested loops, and debugging performance issues can be hard to resolve. The best practice is to break down complex logic into smaller functions and use profiling tools to identify bottlenecks.

    Custom software development at Iron Devs Digital applies these principles to deliver futuristic solutions that are clean, efficient, and scalable.

    But how do you deal with performance issues in your loops, then?

  • + 0 comments

    Great discussion and insights here! For anyone encountering challenges similar to device troubleshooting, especially in situations like water spills on laptops, I found this guide extremely helpful. It outlines immediate steps to prevent damage and ensure a higher chance of recovery. Definitely worth checking out!