+ 2

What's the error in this code??

#include <iostream> #include<string> using namespace std; int main() { string name; cin >> name; try { if(name.size()<4 or name.size()>20) throw 9; cout<<"valid"; } catch(int x) { cout <<"invalid"; } return 0; }

11th Jan 2023, 9:10 AM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar
4 Answers
+ 1
AAYUSH AGARWAL Can you add details or link of code coach? May be it is not passing test case? May be because, output expected the text with first letter is capital .. as "Valid" Or "Invalid" ?
12th Jan 2023, 9:56 AM
Jayakrishna 🇼🇳
+ 2
Jayakrishna🇼🇳 it's solve now, thanks for help
12th Jan 2023, 9:58 AM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar
+ 1
What error you getting? mention in detail..
11th Jan 2023, 10:02 AM
Jayakrishna 🇼🇳
+ 1
Jayakrishna🇼🇳 it is coach problem so it does not verify it's output?
12th Jan 2023, 9:47 AM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar