View Single Post
  #2  
Old 05-09-2008, 12:26 AM
BSIT07-01's Avatar
BSIT07-01 BSIT07-01 is offline
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 34
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Default Re: Assignment} Exercise#4 Question 9 and 11

Solution of Question # 11

Code:
#include <iostream>
using namespace std;

struct time
{
    int hours,minutes,seconds;

};


int main()


{
    time time1,time2,time3;
    int temp;
    char colon;

    cout<<"enter First time in this format (12:30:30):";
    cin>>time1.hours>>colon>>time1.minutes>>colon>>time1.seconds;

    cout<<"enter Second time in this format (12:30:30):";
    cin>>time2.hours>>colon>>time2.minutes>>colon>>time2.seconds;

    long totalseconds1=time1.hours*3600 + time1.minutes*60 + time1.seconds;

    long totalseconds2=time2.hours*3600 + time2.minutes*60 + time2.seconds;

    long totalseconds=totalseconds1+totalseconds2;

    time3.hours=totalseconds/3600;

    temp=totalseconds%3600;

    time3.minutes=temp/60;

    time3.seconds=temp%60;


    cout<<"\nTotal Time: "<<time3.hours<<":"<<time3.minutes<<":"<<time3.seconds<<endl;

    return 0;

}

Reply With Quote