Advertisement
TechOPGOHIL

Untitled

Dec 3rd, 2023
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include<conio.h>
  2. #include<iostream.h>
  3. class map
  4. {
  5. int kilo;
  6. int gram;
  7. public:
  8. map()
  9. {
  10. kilo=0;
  11. gram=0;
  12. }
  13. map(int f)
  14. {
  15. kilo=f/1000;
  16. gram=f%1000;
  17. }
  18. void show()
  19. {
  20. cout<<endl<<" Kilo is :- "<<kilo;
  21. cout<<endl<<" Gram is :- "<<gram;
  22. }
  23. };
  24. int main()
  25. {
  26. int f;
  27. clrscr();
  28. cout<<endl<<" Enter weight in grams : ";
  29. cin>>f;
  30. map t1;
  31. t1=(int)f; /* first method using assignment operator */
  32. /* above statement invoke parameterized constructor */
  33. t1.show();
  34. getch();
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement