Exercise Review
1
An integer cannot meet programming needs.
2
Short shit = 80;
Unsigned shit= 42110;
Auto shit = 3000000000;
3
Do not provide measures, please be careful
4
33L is of the long type and 33 is of the int type.
5
Equivalent
6
(1) int shit = 88; std: cout <(char) shit;
(2) char shit = 88; std: cout < 7
If the floating point type is used to store the decimal digits> = integer digits, there will be no rounding error. Otherwise, there will be.
Check limits. h and float. h and solve the problem by yourself.
8
74 4 0 4.5 3
9
(1) int shit = (int) x1 + (int) x2;
(2) int shit = x1 + x2;
10
Int float char char32_t double
Programming exercises
3.1
# Include
Int main (void) {using namespace std; cout <"Enter your height, in inches \ n"; int inch; cin> inch; cout <"your height" <
3.2
# Include
Int main (void) {using namespace std; const int inch_per_foot = 12; const double meter_per_inch = 0.0254; const double pound_per_kg = 2.2; cout <"Enter your height, feet and inches \ n your feet: "; int foot; cin >>> foot; cout <": "; int inch; cin> inch; cout <"Enter your weight, in LBS \ n your weight is:"; int pound; cin> pound; inch = foot * 12 + inch; double meter = inch * meter_per_inch; double kg = pound/pound_per_kg; double BMI = kg/meter; cout <"your height" <
3.3
# Include
Int main (void) {using namespace std; const int minutes_per_degrees = 60; const int seconds_per_minutes = 60; cout <"Enter a latitude in degrees, minutes, and seconds: \ n "; cout <" First enter the degrees: "; int degrees; cin> degrees; cout <" Next, enter the minutes of arc: "; int minutes; cin> minutes; cout <"Finally, enter the seconds of arc:"; int seconds; cin> seconds; cout <
3.4
# Include
Int main (void) {using namespace std; const int hpd = 24; const int mph = 60; const int spm = 60; const int spd = hpd * mph * spm; const int FLAC = mph * spm; cout <"Enter the number of seconds:"; long seconds; cin> seconds; cout <
3.5
#include
int main(void){ using namespace std; cout<<"Enter the world's population:"; long long world; cin>>world; cout<<"Enter the population of the US:"; long long US; cin>>US; cout<<"The population of the US is "<<(double)US/world*100<<"% of the world population.\n"; return 0;}
3.6
# Include
Int main (void) {using namespace std; const double mpk = 0.6214; const double lpg = 3.785; cout <"input driving distance (Miles)"; double mile; cin> mile; cout <"input fuel consumption (gallon)"; double gallon; cin> gallon; cout <"automotive fuel consumption:" <
3.7
# Include
Int main (void) {using namespace std; const double mpk = 0.6214; const double lpg = 3.785; cout <"input fuel consumption per km (litre)"; double liter; cin> liter; double gallon; gallon = liter/lpg; double mile; mile = mpk * 100; cout <"the fuel consumption per kilometers is" <