Help me in solving LUCKYSEVEN problem

My issue

include
using namespace std;

int main() {
// your code goes here
String str;
cin>>str;
cout<<str[7];
return 0;
}

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	String str[];
	cin>>str[];
	cout<<str[7];
	return 0;
}

Problem Link: LUCKYSEVEN Problem - CodeChef

include
using namespace std;
int main(){
string str;
cin>>str;
cout<<str[6];
}

1 Like

not working

it is working fine you might have not included header file

@shunya71
Use include <bits/stdc++.h>
Instead of iostream

Also you are writing string str there making array of string
You don’t need those square brackets while defining or taking input.
And remember that indexing starts from 0 to N-1…so instead of str[7] use str[6]
These two changes should do it and remember in most case including the header file i mentioned will cut you a lot of hassle so use it regularly
Good luck