Alright, I'm new to the programming world... I've started learning by reading some online tutorials and the book 'C++ Primer'.

I've just gone over some sections on functions and thought I'd make a little program of my own to test out and try out some ideas and get used to functions.

As I'm in Trigonometry right now I thought it'd be fun to have a program convert angle measures in degrees (like 42.35 degrees) into degrees and minutes and seconds (42 degrees 21').

I did it and for most problems it seems to work but for this problem it does not:

42.35 degrees

instead of the 42 degrees and 21 minutes it should solve to it comes up w/ 42 degrees 20 minutes and 59 seconds. ??

Here is the code:

#include <stdlib.h>

#include <iostream>

using namespace std;

int degr(float input);

int minu(float input);

int seco(float input);

int degr(float input)

{

int degrees = input;

return degrees;

}

int minu(float input)

{

int in = input;

float deci = input - in;

int minutes = deci*60;

return minutes;

}

int seco(float input)

{

int in = input;

float deci = input - in;

float semi = deci*60;

int minutes = semi;

float b = semi - minutes;

int seconds = b*60;

return seconds;

}

int main()

{

float input = 0;

int degrees = 0;

int minutes = 0;

int seconds = 0;

cout << "Enter measure of angle in degrees for conversion to minutes and seconds: ";

cin >> input;

degrees = degr(input);

minutes = minu(input);

seconds = seco(input);

cout << "\n\nMeasure of angle in minutes and seconds: " << degrees << " degrees " << minutes << " minutes " << seconds << " seconds" << endl << endl;

system("PAUSE");

return 0;

}

I know its pretty messy now and that a lot of my methods are probably bad but thats all i know how to do right now.

any help is appreciated.

if it matters im running XP using bloodshed's dev-c++ compiler.

oh and after reading the thread at the top i thought id better say that this is not homework or anything... im learning it on my free time and this is just a little program of mine i thought id make. like trying to apply the stuff ive learned you know?

thanks!