Some C++ data types, their format specifiers, and their most common bit widths are as follows:
To read a data type, use the following syntax:
For example, to read a character followed by a double:
scanf("%c %lf", &ch, &d);
For the moment, we can ignore the spacing between format specifiers.
To print a data type, use the following syntax:
For example, to print a character followed by a double:
char ch = 'd';
double d = 234.432;
printf("%c %lf", ch, d);
Note: You can also use cin and cout instead of scanf and printf; however, if you are taking a million numbers as input and printing a million lines, it is faster to use scanf and printf.
Input consists of the following space-separated values: int, long, char, float, and double, respectively.
Print each element on a new line in the same order it was received as input. Note that the floating point value should be correct up to 3 decimal places and the double to 9 decimal places.
3 12345678912345 a 334.23 14049.30493
Print int ,
followed by long ,
followed by char ,
followed by float ,
followed by double .