I can't get this code to work, it is suposed to count seconds when i insert hours minutes and seconds :/ ....but it only gives me the seconds....what have i missed?
#include<iostream.h>
void skrivtotantsek(int anttimmar, int antminuter, int antsekunder);
void main()
{
int min,tim,sek;
cout<<"Ange timmar: ";
cin>>tim;
cout<<"Ange minuter: ";
cin>>min;
cout<<"Ange sekunder: ";
cin>>sek;
skrivtotantsek(tim,min,sek);
}
void skrivtotantsek(int anttimmar, int antminuter, int antsekunder)
{
int totantsek;
totantsek = (anttimmar/60/60)+(antminuter/60)+antsekunder;
cout<<"Detta ger totalt "<<totantsek<<" sekunder"<<endl;
}
c++ simpel code....help please =P
c++ simpel code....help please =P
"The best place to hide a tree, is in a forest"
-
- cyber messiah
- Posts: 1201
- Joined: 30 Apr 2006, 16:00
- 16
- Location: 127.0.0.1
it would be multiplication instead of divisiontotantsek = (anttimmar/60/60)+(antminuter/60)+antsekunder;
try this
Code: Select all
totantsek = (anttimmar*3600)+(antminuter*60)+antsekunder;