We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 76f230f commit 3254decCopy full SHA for 3254dec
16 - Exceptions - String to Integer/Solution.cpp
@@ -0,0 +1,18 @@
1
+#include <iostream>
2
+
3
+using namespace std;
4
5
+int main() {
6
+ try {
7
+ string str;
8
+ cin >> str;
9
10
+ int num = stoi(str);
11
+ cout << num;
12
+ }
13
+ //Aditya Seth
14
+ catch (...) {
15
+ cout << "Bad String";
16
17
+ return 0;
18
+}
16 - Exceptions - String to Integer/Solution.kt
@@ -0,0 +1,9 @@
+fun main(args: Array<String>) {
+ val inputString = readLine()
+ val integer = Integer.parseInt(inputString)
+ println(integer)
+ } catch (numberFormatException: NumberFormatException) {
+ println("Bad String")
16 - Exceptions - String to Integer/Solution.py
@@ -0,0 +1,6 @@
+try:
+ print(int(input().strip()))
+except ValueError:
+ print("Bad String")
+#Aditya Seth
0 commit comments