Concept Flow - Multiple input and output
Start
Read input1, input2
Process inputs
Output result1, result2
End
The program reads multiple inputs, processes them, and then outputs multiple results.
#include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << a + b << " " << a * b << endl; return 0; }
| Step | Action | Input Values | Variables After | Output |
|---|---|---|---|---|
| 1 | Start program | - | a: uninitialized, b: uninitialized | - |
| 2 | Read inputs | a=3, b=4 | a:3, b:4 | - |
| 3 | Calculate sum and product | - | a:3, b:4 | - |
| 4 | Output results | - | a:3, b:4 | 7 12 |
| 5 | End program | - | a:3, b:4 | - |
| Variable | Start | After Input | After Calculation | Final |
|---|---|---|---|---|
| a | uninitialized | 3 | 3 | 3 |
| b | uninitialized | 4 | 4 | 4 |
Multiple input and output in C++: - Use 'cin >> var1 >> var2;' to read multiple inputs. - Use 'cout << val1 << " " << val2 << endl;' to output multiple values. - Inputs and outputs can be on the same line. - Variables hold input values for processing. - Program ends after outputting results.