Advertisement
Icalized

Untitled

Aug 22nd, 2022
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int const size=50;
  5.  
  6. class vector
  7. {
  8. float d[size];
  9. int s;
  10. public:
  11. void create(void);
  12. void modify(void);
  13. void multiply(void);
  14. void display(void);
  15. };
  16.  
  17. void vector :: create(void)
  18. {
  19. cout<<"\nEnter of Array you want to create: ";
  20. cin>>s;
  21. cout<<"Enter "<<s<<" Real Numbers: ";
  22. for(int i=0;i<s;i++)
  23. cin>>d[i];
  24. }
  25.  
  26. void vector :: modify(void)
  27. {
  28. int mfy_value;
  29. float with;
  30. cout<<"\nEnter Location of array at which value is to be modified: ";
  31. cin>>mfy_value;
  32. cout<<"Enter Value with which you want to Replace: ";
  33. cin>>with;
  34. d[mfy_value]=with;
  35. }
  36.  
  37. void vector :: multiply(void)
  38. {
  39. int mul;
  40. cout<<"\nEnter value with which you want to multiply: ";
  41. cin>>mul;
  42. for(int i=0;i<s;i++)
  43. d[i]=d[i]*mul;
  44. }
  45.  
  46. void vector :: display(void)
  47. {
  48. cout<<"\n\nDisplay of Array\n";
  49. cout<<"(";
  50. for(int i=0;i<s;i++)
  51. {
  52. cout<<d[i];
  53. if(i!=s-1)
  54. cout<<",";
  55. }
  56. cout<<")\n";
  57. }
  58. int main()
  59. {
  60.  
  61. vector o1;
  62. int choice;
  63. do
  64. {
  65. cout<<"\nChoice List\n";
  66. cout<<"1) To Create Vector Array\n";
  67. cout<<"2) To Modify Array\n";
  68. cout<<"3) To Multiply with Scalar value\n";
  69. cout<<"4) To Display\n";
  70. cout<<"5) EXIT\n";
  71. cout<<"Enter your choice: ";
  72. cin>>choice;
  73. switch(choice)
  74. {
  75. case 1: o1.create();
  76. break;
  77. case 2: o1.modify();
  78. break;
  79. case 3: o1.multiply();
  80. break;
  81. case 4: o1.display();
  82. break;
  83. case 5:return 0;
  84. }
  85. }while(1);
  86. end:
  87. return 0;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement