Q:
Golang program to demonstrate the fmt.Scan() function
belongs to collection: Golang Basic Programs
Golang Basic Programs
- Golang program to print Hello World
- Golang program to add two integer numbers
- Golang program to find the average of three numbers
- Golang program to read and print an integer variable
- Golang program to swap two integer numbers
- Golang program to demonstrate the use of Printf() and Scanf() function
- Golang program to get the ASCII value of a character
- Golang program to print the absolute value of float number
- Golang program to print the absolute value for an integer number
- Golang program to calculate the power of a number using the Pow() function
- Golang program to find the largest number between two numbers using math.Max() function
- Golang program to find the smallest number between two numbers using math.Min() function
- Golang program to demonstrate the math.Ceil() function
- Golang program to demonstrate the math.Floor() function
- Golang program to find the remainder for floating-point numbers using math.Mod() function
- Golang program to find the IEEE 754 representation using math.Float64bits() function of given number
- Golang program to check given number is EVEN or ODD
- Golang program to check given number is positive or negative
- Golang program to check given year is a leap year or not
- Golang program to find the largest number between two numbers
- Golang program to find the largest number among three numbers
- Golang program to convert the Fahrenheit to Celsius
- Golang program to convert the Celsius to Fahrenheit
- Golang program to demonstrate the bitwise Left Shift (<<) operator
- Golang program to demonstrate the bitwise Right Shift (>>) operator
- Golang program to demonstrate the BITWISE AND (&) operator
- Golang program to demonstrate the BITWISE OR (|) operator
- Golang program to demonstrate the BITWISE XOR (^) operator
- Golang program to demonstrate the NOT (!) operator
- Golang program to calculate the area of the circle
- Golang program to calculate the perimeter of the circle
- Golang program to calculate the area of the Rectangle
- Golang program to demonstrate the \'const\' keyword
- Golang program to demonstrate Sizeof() operator
- Golang program to demonstrate the \'defer\' keyword
- Golang program to demonstrate the \'defer\' keyword to add two numbers
- Golang program to print the type of specified variable using format specifier in printf() function
- Golang program to print the binary value of a specified number using format specifier in printf() function
- Golang program to print the octal value of a specified number using format specifier in Printf() function
- Golang program to print the hexadecimal value of a specified number using format specifier in printf() function
- Golang program to print the floating-point value in scientific notation
- Golang program to print the string in double-quotes using format specifier
- Golang program to print the variable address using \'%p\' format specifier
- Golang program to demonstrate the io.WriteString() function
- Golang program to print the Boolean value using format specifier in fmt.Printf() function
- Golang program to demonstrate the fmt.Scan() function
- Golang program to print \'%\' on the console screen using fmt.printf() function
- Golang program to demonstrate the fmt.Sprintf() function
- Golang program to demonstrate the fmt.Sscanf() function
- Golang program to use the expression in the case statement
Program/Source Code:
The source code to demonstrate the fmt.Scan() function is given below. The given program is compiled and executed on the ubuntu 18.04 operating system successfully.
Output:
Explanation:
In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt package then we can use a function related to the fmt
In the main() function, we created a string variable str. Then we read a string from the user using fmt.Scan() function. After that, we printed the input string on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer