Please Help

closed account (2Up4izwU)
i have to answer this:

Write an algorithm (without modules) that asks the user to input the elapsed time for an event in seconds. The algorithm then outputs the elapsed time in hours, minutes and seconds.
(For example, if the elapsed time is 9630, then the output is 2:40:30)
2. Rewrite the previous algorithm with three modules in addition to the Control module.
3. Translate the algorithm created in part 1 into a C++ program without functions.
4. Translate the algorithm created in part 2 into a C++ program with functions.
We won't do it for you. Do your best. If you get stuck, post your code and ask away.
closed account (2Up4izwU)
ok
give me some tips ;) and i will do it
How many seconds make up 1 minute? How many minutes equals 1 hour?
Tip: Start a new C++ project, add the main entry point and code what you need to code. Don't know what goes into the main entry point? Well, then ask. But show the main entry point as you have it.
closed account (2Up4izwU)
yahuuu

i need now to write it wt fuctions .. but how ?? any tips ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;
int main ()


{
int time_sec;

cout<<"Enter the time in seconds to otput the time in hours, minutes and seconds: \n";
cin>>time_sec;

cout<<"Here it is in Hours, Minutes, Secounds:\n"<<(time_sec/3600)<<":"<<(time_sec%3600)/60<<":"<<((time_sec%3600)%60);

return 0;
}
Last edited on
See? Wasn't very hard and it is much more rewarding if you do as opposed as if it is given to you.

Want to learn functions? Start here: http://www.cplusplus.com/doc/tutorial/functions/ .
closed account (2Up4izwU)
but how can i write it with functions
i didnt got it
1
2
3
4
int function( int time_s)
{
/// here goes your code 
}
closed account (2Up4izwU)
this is an exp. for a code with functions .. i want to do it like that

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
using namespace std;
float Read ();
float Calc_Cr (float);
float Calc_Area (float);
void print (float, float);
const float Pi=3.14;


void main ()
{
float radius, area, circum ;
radius = Read ();
circum = Calc_Cr (radius);
area = Calc_Area (radius);
print (circum, area);
}



float Read ()
{
float r ;
cout<< "Enter the Radius:\n";
cin>> r;
return r;
}


float Calc_Cr (float r)
{
    return 2*Pi*r;
}

float Calc_Area (float r )
{
return Pi*r*r;
}

void print (float c, float a)
{
cout << "Circum = " << c<<endl;
    cout <<"Area = " << a<<endl;

    system ("pause");
} 
yes .. you are right .. but try to apply in your program
closed account (2Up4izwU)
yeah but how ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;
int Read ();
int Calc_time_sec(int);
int Print (int);

int main (){
int time_sec;
time_sec = Read();
int void  Print ()
}

cout<<"Enter the time in seconds: \n";
cin>>time_sec;
cout<<"Here it is in Hours, Minutes, Secounds:\n"<<(time_sec/3600)<<":"<<(time_sec%3600)/60<<":"<<((time_sec%3600)%60);
return 0;


i know its wrong i dono how should i start ?? !!

i read the tut but i want to apply
closed account (2Up4izwU)
? i need funtion that read,calculate,and Print..
closed account (2Up4izwU)
?????//////
you have to try first ..
Topic archived. No new replies allowed.