Home » Julia

Single character input in Julia

Julia | Character Input: In this tutorial, we are going to learn how to take input of a single character in Julia?
Submitted by IncludeHelp, on April 02, 2020

Julia | Character Input

In Julia programming language, we can use read() function to input a single character at the run-type by using the following syntax:

    read(stdin, Char)

Here, stdin is a global variable that refers to the standard input stream and Char is the data type that represents a single character.

Example:

# Julia program to take single character input

print("Input a character: ")
x = read(stdin, Char)

println("Input character is: ", x)

Output

RUN 1:
Input a character: G
Input character is: G

RUN 2:
Input a character: x
Input character is: x

RUN 3:
Input a character: Hello
Input character is: H
ello
ERROR: UndefVarError: ello not defined


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.