Module: (C++) Variables. Output formats


Problem

3/7

How input a data into variable

Theory Click to read/hide

The input statement

In order for the user to be able to set the value of the variable himself, it is necessary to be able to input values from the keyboard.
 Handling the standard input in C++ is done by applying the operator cin >> variable_name .
cin >> a; 
After this operator, the data that is input from the keyboard to store it in a a-variable.
It is possible to combine several cin statements into one
For example:
cin >> a;
cin >> b;
performs the same actions as the record
cin >> a >> b;
that is, the first data entered is entered into the variable a, the second into the variable b
 
Advanced Material
For input data from the keyboard an input operator is used, which in general has the following structure
scanf ("<input formats>", <variable's address>);
Input formats  – this is a quoted string listing one or more data input formats.
For example, the most commonly used
%d input an integer variable (variable of type int)
%f input a real variable (variable of type  float)
input a one symbol (variable of type char)

For example,
scanf ("%d%d", &a, &b);


This operator, waits for an input from the keyboard the values of two integer variables. The first number input from the keyboard will store to cell a, the second to cell b.
 
After the input format, the addresses of the memory cells to which the inputed values are written are listed with a comma. Variable values are inputed by specifying the address of this variable. Therefore, it is necessary to put an ampersand sign in front of the variable name: &a is the address of the variable a.
The number of input formats and and the number of variables must match!

Problem

Rabbit Clever began to study the input operator, so that his programs became more universal and worked on different sets of values.
He wants to input the values ​​of 6 variables from the keyboard and output them on the screen to make sure that they are in the necessary variables. But he made some mistakes in the program.
Help him fix them.

1. In the fifth and sixth lines, correct errors when writing input operators so that the values ​​of the variables specified in the line are entered, use one cout command in each line
2. On the seventh line, write down the input operator yourself, which enters the values ​​of the two variables e and f. Use one input command
3. In the eighth line, write the operator for outputing the values ​​of all variables on the screen in alphabetical order with a space