Skip to content

User Input Output

graph LR

  A(Start) --> B[Declare Variables];
  B --> C[Read User Input];
  C --> D[Process Input];
  D --> E[Generate Output];
  E --> F[Display Output to User];
  F --> G(End);

  style A fill:#f00,color:white,font-weight:bold,stroke-width:2px,stroke:yellow
  style G fill:#00f,color:white,font-weight:bold,stroke-width:2px,stroke:yellow

  subgraph Declare_Variables
    B[Declare Variables]
  end

  subgraph Read_User_Input
    C[Read User Input]
  end

  subgraph Process_Input
    D[Process Input]
  end

  subgraph Generate_Output
    E[Generate Output]
  end

  subgraph Display_Output
    F[Display Output to User]
  end

  style Declare_Variables fill:##FC33FF,stroke:#FF6E40,stroke-width:4px;
  style Read_User_Input fill:##FC33FF,stroke:#3A9D23,stroke-width:4px;
  style Process_Input fill:##FC33FF,stroke:#4D5BFF,stroke-width:4px;
  style Generate_Output fill:##FC33FF,stroke:#FF406A,stroke-width:4px;
  style Display_Output fill:##FC33FF,stroke:#0082FF,stroke-width:4px;

Input

User Input in C++

To read input from the user in C++, you can use the cin stream. Here's an example of how to read an integer from the user

Input.cpp

1
2
3
4
5
6
7
8
9
#include <bits/stdc++.h>
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    cout << "Value of x=" << x << " and y=" << y;
    return 0;
}

Input: 10 11
Output: Value of x=10 and y=11

User Input in Python

To read input from the user in Python, you can use the input() function. Here's an example of how to read a integer from the user

Input.py

x, y = list(map(int, input().split()))
print("Value of x=", x, "and y=", y)

Input: 10 11
Output: Value of x=10 and y=11

Output

User Output in C++

To display output to the user in C++, you can use the cout stream. Here's an example of how to output a message to the user

Output.cpp

1
2
3
4
5
6
7
8
#include <bits/stdc++.h>
using namespace std;

int main() {
    cout << "Hello," << endl;
    cout << "My Name is " << "Akash Singh" << endl;
    return 0;
}

Output: Hello,
My Name is Akash Singh

User Output in Python

To display output to the user in Python, you can use the print() function. Here's an example of how to output a message to the user

Output.py

print("Hello,")
print("My Name is", "Akash Singh")

Output: Hello,
My Name is Akash Singh