+ 1

How to take two inputs in the same line

For e.g. "Enter 2 integers"n1,n2. is this really possible?

19th Aug 2017, 6:00 PM
Debarghya Ghosh Dastidar
Debarghya Ghosh Dastidar - avatar
2 Answers
+ 4
What language? It is possible, but varies depending on the language used and in some cases the type of input needed. For instance, in Java you can get 2 integers from the same string input using a Scanner and its nextInt() method: Scanner sc = new Scanner(System.in); System.out.print("Enter two space separated integers: "); // User inputs "100 54" int firstInt = sc.nextInt(); // firstInt is 100 int secondInt = sc.nextInt(); // secondInt is 54
19th Aug 2017, 6:09 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
thanks, it's for java
19th Aug 2017, 6:13 PM
Debarghya Ghosh Dastidar
Debarghya Ghosh Dastidar - avatar