Use of auto keyword

what is auto keyword and why is it used here in this session keeping in mind we know the type of variable

hi @kunalverma2468_930e4c6186515a70
auto is just a keyword used for traversing over an array, string or any other data structure…
eg.

#include <iostream>
using namespace std;
int main() {
    string str = "Hello";
    for(auto x:str){
        cout<<x;
    }
}

o/p will be Hello

Sir I wrote this code it’s showing two errors

  1. For auto keyword and
  2. For for each loop
    How to resolve this

Kindly share ur code…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.