Logo

Programming-Idioms

  • Pascal
  • Lua
  • Java

Idiom #120 Read integer from stdin

Read an integer value from the standard input into the variable n

import java.util.Scanner;
Scanner in = new Scanner(System.in);
n = in.nextInt();
import static java.lang.Integer.parseInt;
import java.util.Scanner;
Scanner s = new Scanner(System.in);
int n = parseInt(s.nextLine());
s.close();
import java.util.Scanner;
Scanner in = new Scanner(System.in);
int n = in.nextInt();
read(n);
n = io.read("n")
#include <stdio.h>
int n;
scanf("%d", &n);

New implementation...