July 10, 2011

print any real number and print the integer part and the real part separately without using modulus

print any real number and print the integer part and the real part separately without using modulus

 class date  
 {  
 int dd,mm,yy;  
 public: void input()  
 { cout<<"Enter the date :"<>dd;  
 cout<<"Enter the month :";  
 cin>>mm;  
 cout<<"Enter the year :";  
 cin>>yy;  
 }  
 void calc()  
 {int n,p;  
 cout<<"Enter the number of days"<>n;  
 dd=dd+n;  
 if(dd>30)  
 {mm=mm+(dd%30);  
 dd=dd+(dd/30);  
 }  
 if(mm>12)  
 yy=yy+(mm%12)  
 }  
 void display()  
 { cout<<"The new date="<<dd<<"/"<<mm<<"/"<<yy<<endl;  
 }  
 };  
 void main()  
 {clrscr();  
 date d;  
 d.input();  
 d.calc();  
 d.display();  
 getch();  
 }