## PIC 10A

(Sec. 3a-3d)

C++ Programming and Problem Solving

## Instructor: Ivo Dinov, Asst. Prof.

 http://www.math.ucla.edu/~dinov/courses_students.dir/PIC10A_CPP_Spring01.dir/PIC10A_CPP.html

Due Date:

# Wednesday, 8:00 PM, Apr. 18, 2001

• Here is a program. Would it compile without errors? Are there any logical, design or syntax errors?
#include
using namespace std;
int main()
{
int x;
x = x + 3;
cout << x << endl;
return 0;
}

• Write a program that converts temperature in degrees Celsius (Co) to degrees Fahrenheit (Fo). The following formula expresses the relation between the two scales Fo = (9/5)*Co + 32.0. Before each scale conversion ask the user if an Fo --> Co or an Co --> Fo computation is requested, and of course, perform the desired calculation. After each conversion, ask the user (Y/N) if more Fo <--> Co computations are needed. Continue, prompting the user and computing until the user enters N (No).

• Write a program that reads in a series of integers, until a 0 (zero) is entered. Then report the sum (S), the mean (m) and the sum of the squares (SS) of the numbers. NOTE: If {x1, x2, ..., xn} are entered, then S = x1 + ... + xn, m = S/n and SS =x12 + ...+xn2.

\Ivo D. Dinov, Ph.D., Department of Neurology and Program in Computing, UCLA School of Medicine/