BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Right Header

Register FAQ Community Calendar New Posts Navbar Right Corner
HOME BZU Mail Box Online Games Radio and TV Cricket All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan > Institute of Computing > Bachelor of Science in Information Technology > BsIT 3rd Semester > Object Oriented Programming

Object Oriented Programming By Mam Sidra Malik


 
 
Thread Tools Search this Thread Rating: Thread Rating: 6 votes, 4.67 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-09-2008, 09:06 PM
BSIT07-01's Avatar
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 Solution of Ex 5,6,2 & 4 Ch# 5 Robert Lafore OOP c++


Solution of Exercise 5


Code:
#include <iostream>
using namespace std;


long hms_to_secs(int h,int m,int s)

{
    long seconds;

    seconds=h*3600+m*60+s;
    return seconds;

}

void main()


{

char c;
int h,m,s;
for(int n=1;n<10;n++)
{
cout<<"enter time in this formate 12:12:49  :  ";

cin>>h>>c>>m>>c>>s;

cout<<hms_to_secs(h,m,s)<<endl;
}

}



Solution of Exercise 6


Code:
#include <iostream>
using namespace std;

struct time
{
    int hours,minutes,seconds;

};

long time_to_secs(time);

time secs_to_time(long);

int main()


{
    time time1,time2;
    
    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=time_to_secs(time1);

    long totalseconds2=time_to_secs(time2);

    long totalseconds=totalseconds1+totalseconds2;

    time totaltime=secs_to_time(totalseconds);


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

    return 0;

}

long time_to_secs(time time1)

{


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

return totalseconds;
}


time secs_to_time(long totalseconds)

{
    int temp;
    time time3;

    time3.hours=totalseconds/3600;

    temp=totalseconds%3600;

    time3.minutes=temp/60;

    time3.seconds=temp%60;

    return time3;

}


Ahmad ne kaha tha mein kar doon ga post...
Ahmad ne tu post karnay hi nahin hain, Main he kar daita hoon

Reply With Quote
 

Tags
assignment, c++, ch#, lafore, oop, robert, solution


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fraction Calculator with 4 functions in c++ [ex12 of ch#5] Robert Lafore BSIT07-01 Object Oriented Programming 7 08-10-2011 10:02 AM
[Assignment] Solution Q no 1 ch#9 Object Oriented Programming in c++ by Robert Lafore BSIT07-01 Object Oriented Programming 1 15-03-2011 08:09 PM
Solution.. Raheel Quotes 0 23-02-2010 10:50 AM
NEW Fundalmentals PHYSICS Complete Solution by Halliday, Resnick, and Krane-sol_solv1 Complete Solution Nadeem Iqbal BsCS 3rd Semester 4 26-10-2009 06:10 PM
[Assignment] Q no 5 ch#9 Object Oriented Programming in c++ by Robert Lafore BSIT07-01 Object Oriented Programming 0 13-11-2008 01:02 AM

Best view in Firefox
Almuslimeen.info | BZU Multan | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 06:35 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.