Logo

Programming-Idioms

  • Python
  • Scala
  • C++

Idiom #120 Read integer from stdin

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

import scala.io.StdIn
import scala.util.Try
val n = Try(StdIn.readInt())
n = int(input("Input Prompting String: "))
n = int(input())
#include <iostream>
std::cin >> n;
#include <stdio.h>
int n[15];
fgets(n, 15, stdin);

int n[15]; Int with 15 bytes to use.

Fgets gets user input, and sets n to what it gets

New implementation...