VOOZH about

URL: https://www.geeksforgeeks.org/dsa/input-and-output-in-programming/

⇱ Input and Output in Programming - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Input and Output in Programming

Last Updated : 26 Mar, 2026

Input and Output (I/O) are fundamental concepts in programming.

  • Input allows a program to receive data from the user, files, or other sources, while output allows it to display results.
  • I/O is essential for creating interactive programs and performing tasks with dynamic data.


Input Output in C

stdio.h is the library in C that provides functions for input and output, like printf() and scanf().

  • printf() is used to display messages or values on the screen. You can print text, numbers, and variables.
  • scanf() is used to read input from the user and requires a format specifier to know the type of data.
  • \n is used to move to a new line so that the next output appears below the previous one.
  • Format specifiers tell C what type of data to read or print, for example: %d for integers, %f for floats, %c for characters, and %s for strings.

Input:

20 5.9 A Alice

Output:

Your age: 20
Your height: 5.90
Your grade: A
Your name: Alice

Input Output in CPP

#include <iostream> is the library in Cpp that provides input/output functions like cout and cin.

  • cout is used to display messages or values on the screen. You can print text, numbers, and variables.
  • cin is used to read input from the user. The variable type determines the kind of input it accepts.
  • \n or endl is used to move to a new line in output.

Input:

20 5.9 A Alice

Output:

Your age: 20
Your height: 5.9
Your grade: A
Your name: Alice

Input Output in Java

Scanner (from java.util.Scanner) is used for input, and System.out is used for output.

  • System.out.println() displays messages or values on the screen and moves to a new line.
  • System.out.print() displays messages without moving to a new line.
  • Scanner.nextInt(), nextFloat(), next(), nextLine() are used to read different types of input from the user.

Input:

20 5.9 A Alice

Output:

Your age: 20
Your height: 5.9
Your grade: A
Your name: Alice

Input Output in Python

Python does not require a separate library for input/output; it uses built-in functions.

  • print() is used to display messages or values on the screen. You can print text, numbers, or variables.
  • input() is used to read input from the user as a string; type conversion (int(), float()) is used for numbers.
  • \n is used inside print() to move to a new line; print() automatically moves to a new line by default

Input:

20 5.9 A Alice

Output:

Your age: 20
Your height: 5.9
Your grade: A
Your name: Alice

Input Output in C#

System namespace provides input/output functions, and Console is used for I/O.

  • Console.WriteLine() displays messages or values on the screen and moves to a new line.
  • Console.Write() displays messages without moving to a new line.
  • Console.ReadLine() reads input from the user as a string; type conversion is needed for other types like int.Parse() or float.Parse().

Input:

20 5.9 A Alice

Output:

Your age: 20
Your height: 5.9
Your grade: A
Your name: Alice

Input Output in JavaScript

In Node.js, input/output is handled using readline module for input and console.log() for output.

  • console.log() displays messages or values on the screen and moves to a new line.
  • console.print() is not standard; output is mostly done via console.log().
  • Input is read using readline.question() in Node.js or prompt() in browsers.

Input:

20 5.9 A Alice

Output:

Your age: 20
Your height: 5.9
Your grade: A
Your name: Alice

Comment
Article Tags:
Article Tags: