Lab 6 (Spring 2013) Class: Name: Student ID: Note: Please

Lab 6 (Spring 2013)
Class:
Name:
Student ID:
Note: Please complete and return this assignment as your homework. Remember to write down
your name and student ID#.
1. Please complete the following program. Print and submit screenshots of your codes and
output display. Explain the differences among the four kinds of operators: the prefix
increment operator, the postfix increment operator, the prefix decrement operator, and
the postfix decrement operator.
2. Write C++ statements for the following:
a. b=sin x−cos x
b. b=sin 2 x−cos 2 x
c. area =c×b×sin a /2
d. c= a 2 b2
e. p=∣m−n∣
f. total =
a r n−1
r −1
3. Design, write, compile, and execute a C++ program to convert temperature in degrees
Fahrenheit to degrees Celsius. The equation for this conversion is:
Celsius = 5.0 / 9.0 (Fahrenheit – 32.0)
Have your program convert and display the Celsius temperature corresponding to 98.6
degrees Fahrenheit. Your program should produce the following display:
For a Fahrenheit temperature of 98.6 degrees, the
equivalent Celsius temperature is _____ degrees.
Or,
當華氏溫度為 98.6 度時,攝氏溫度是 _____ 度
where appropriate values are inserted by your program in place of the underlines. Print
and submit screenshots of your codes and output display.
4. The set of linear equations
a 11 X 1a 12 X 2=c 1
a 21 X 1a 22 X 2=c 2
can be solved using Cramer's rule:
X 1=
c 1 a 22−c 2 a12
a11 a 22−a 12 a 21
X 2=
c 2 a 11−c 1 a 21
a 11 a 22−a 12 a 21
Using these equations, write, compile, and execute a C++ program to solve for the
X 1 and X 2 values that satisfy the following equations:
3 X 14 X 2 =40
5 X 12 X 2=34
Print and submit screenshots of your codes and output display.