Help me do some calculations in C++

Status
Not open for further replies.

nyadimo

Junior Member level 2
Joined
Mar 1, 2007
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,427
hi i appreciate your assisstance.

how would you approach these two questions.

1) The distance between 2 points in a co-ordinate system is given by the formula
√(x1-X2)²+ (y1-y2)²
Write a program to read in the coordinates of two points and write out the distance between them.

2) Statistics of the rainfall for a town has been collected for ten years. Write a program to read the in the information for ten years and present the results in form of a histogram. Assume the rainfall ranges from 0-200 mm. (output as a horizontal histogram)



the codes would be appreciated
 

Re: c++ programming

Hi nyadimo,

This is very basic and simple and it looks like a homework signment.
I'd like to help you, but I shouldn't do your homework for you. ;-)
So I will give some hints, instead of the complete sourcecode to do it...

1.
x^y can be calculated with the function pow(x,y) (be sure to include <math.h>)

2.
This is very dependant on the libraries to your disposal.
If you use VC it's dependant on weather your program is a MFC appl with a doc/view structure, or a dialog or even a console...
You can only expect to get help on this subject if you specify this more precisely.

Hope this helps,
JB
 

c++ programming

For Root use sqrt(), and for square use Pow() method of math.h use simple formula for calculating distance
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…