jeudi 28 octobre 2021

I need help in c++ change cases

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string sentence =""; 
    cin >> sentence; //aab
    int i;
    
    for (i=0;i=sentence.length();i++){ 
        if (i<=65 && i>=90) {
            sentence = sentence[i] + 32;
        }
        else if (i<=97 && i>=122){                //i=0,
            sentence = sentence [i]-32;
        }
        
        
    }

    cout << sentence;
    return 0;
}

When I enter this code for changing cases of letters it keeps asking me to enter more although I have only one cin in the code why does that happen?

Aucun commentaire:

Enregistrer un commentaire