02-01-2011, 03:49 AM
Xpert Wrote:Code:#include<iostream.h> class multiply { private: int myarry[10]; public: //Constructor initializing array for all four objects of class! multiply() { for(int i=0;i<=9;i++) { myarry[i]=0; } } //returns values of objects a and b on the screen void getter(multiply a,multiply b) { cout<<"Values for object a are:-"<<endl; for(int t=0;t<=9;t++) { cout<<"Value"<<"."<<t<<"\t"<<a.myarry[t]<<endl; } cout<<"Values for object b are:-"<<endl; for(int s=0;s<=9;s++) { cout<<"Value"<<"."<<s<<"\t"<<b.myarry[s]<<endl; } } //takes values from user for objects a and b void setter(multiply x,multiply y,multiply z) { cout<<"Enter values in array for object a"<<endl; for(int m=0;m<=9;m++) { cout<<"Value Please?"<<endl; cin>>x.myarry[m]; } cout<<"Enter values in array for object b"<<endl; for(int n=0;n<=9;n++) { cout<<"Value Please?"<<endl; cin>>y.myarry[n]; } getter(x,y); calculate(x,y,z); } //performs the multiplication void calculate(multiply a,multiply b,multiply c) { for(int bee=0;bee<10;bee++) { c.myarry[bee]=a.myarry[bee]*b.myarry[bee]; } result(c); } //outputs result void result(multiply f) { cout<<"Your Result is"<<endl; for(int h=0;h<10;h++) { cout<<h<<"-"<<f.myarry[h]<<endl; } } }; void main() { multiply o,a,b,c; o.setter(a,b,c); }
this is solution of cs201 assignment # 5 spring 2010