CEG220: Introduction to C
Programming for Engineers – I
Section 2
Homework for Week 2
1) Write a program that asks for two coordinates, P1 = (x1, y1, z1) and P2 = (x2, y2, z2) and computes the distance between them.
2) Write
a program that rounds a number to the nearest (a) tenth, (b) hundredth, (c)
thousandth. HINT: you don’t even need math.h
3) When do you want to use a char, short, int, or long int to store an integer value? When do you want to make a value unsigned? What’s the difference between a float and a double?
4) Under what circumstances should you use a function instead of a macro? When do you want to use a global constant instead of a macro?
1) Let’s say you have a triangle such as below. A = 60º. Compute the value of the remaining side
