skip to main
|
skip to sidebar
C++ Programs
Based on cusat cs 3rd sem 2009 lab cycle
Thursday, October 21, 2010
Decrement time by one using operator overloading(External questn 2009)
#include<iostream.h> #include<conio.h> class time { int h,m,s; public: time() { h=0,m=0;s=0; } void getdata(); void show(); void operator--(); }; void time::getdata() { do{ cout<<"\n Enter the hour(0-11) "; cin>>h; }while(h<0||h>11); do{ cout<<"\n Enter the minute(0-59) "; cin>>m; }while(m<0||m>59); do{ cout<<"\n Enter the second(0-59) "; cin>>s; }while(s<0||s>59); } void time::show() { cout<<h<<":"<<m<<":"<<s; } void time::operator--() { int a,b; s--; if(s==-1) { s=59; m--; if(m==-1) { m=59; h--; if(h==-1) h=11; } } } void main() { clrscr(); time t1; cout<<"\n Enter the time "; t1.getdata(); cout<<"\n Before decrementing "; t1.show(); --t1; cout<<"\n After decrementing "; t1.show(); getch(); }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Home
8085 programming
Datastructure
Graphics programming
8086 Programming
LEX, YACC and parsers
Operating System
Programzz!
Add two date using operator overloading
Add two date using class
Decrement time by one using operator overloading(E...
Add two time using operator overloading(External q...
Compare two string. use operator overloading(Exter...
Matrix multiplcation(External Questn-2009)
Difference between two dates
Generic programming
File manipulation
Pure Virtual Function
Virtual Function
Multipath Inheritance
Hybrid Inheritance
Hierarchical inheritance
Addition of two distances using friend function
Class to class conversion
Basic to class and class to basic conversion
Operator functions as friend functions
Function overloading.
Static & Constant function
User defined string functions
Complex numbers using operator overloading.
Inline function
Add two time
Differnt temprature scale(Farenheit/celsius/kelvin).
Students details- using class
Students details- using structure
Check whether a date is valid or not
pass by value, pass by address, pass by refrence
Followers
Blog Archive
▼
2010
(29)
►
December
(2)
▼
October
(4)
Decrement time by one using operator overloading(E...
Add two time using operator overloading(External q...
Compare two string. use operator overloading(Exter...
Matrix multiplcation(External Questn-2009)
►
July
(1)
►
May
(22)
About Me
Arun Ramesh
View my complete profile
No comments:
Post a Comment