Sponsored Links


Results 1 to 10 of 10

Thread: CS201 assignment #5

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    12

    CS201 assignment #5

    Sponsored Links1


    Problem Statement: Multiplication of two objects of same class
    • You are required to write a class. Class should have an array of 10 integers as its private data member.
    Class should have
    • A default constructor which will initialize all array elements with zero.
    • Getter and setter functions
    • An operator overloading function which will overload * operator for this class.

     You are required to create three objects of the same class.
     You must assign values to first and second objects through setter functions. You can either take input arrays from user or use hard coded values.
     Display the values of first and second object through getter functions.
     Multiply both objects and store the result of multiplication in third object.
     Multiplication means the 1st element of member array of object1 should be multiplied by 1st element of member array of object2. Similarly, 2nd element should be multiplied with 2nd and so on. In the end, display the result stored in third object.
     Your program should support the statement like a = b * c, where a, b and c are objects of the same class.

    -------------------------------------------------------------------------
    Sample output:
    Object 1 :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    Sponsored Links

    Object 2 :
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1

    Multiplication of both objects :
    10
    18
    24
    28
    30
    30
    28
    24
    18
    10

    plz give me solution.............

  2. #2
    Senior Member viki's Avatar
    Join Date
    May 2010
    Posts
    2,132
    what is the dua date aur jab bhi assignment for solution upload karoo to also mention the dua date of it
    :o:o--------------------------------------------------------------------------------------:o:o
    [B]The more knowledge you have, the greater will be your fear of Allah.[/B]

    Please Join My [B]Group Vuhelp[/B][B], Birthday Wishing, Daily Hadees[/B] [CODE][B]http://vuhelp.net/groups/vuhelp.html[/B]
    [B]http://vuhelp.net/groups/birthday-wishing.html[/B]
    [B]http://vuhelp.net/groups/daily-hadees.html[/B][/CODE]
    [CENTER][B][COLOR="Red"][SIZE="4"]Email: [email]viki@vuhelp.net[/email][/SIZE][/COLOR][/B][/CENTER]

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    12
    15th july sir

  4. #4
    Junior Member
    Join Date
    Jul 2010
    Posts
    2

    Assignment Sol.

    #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);
    }

  5. #5
    Senior Member sanam's Avatar
    Join Date
    May 2010
    Location
    sky
    Posts
    217
    itna lamba solution yah app nay khud banaya hai?

  6. #6
    Junior Member M.Ali's Avatar
    Join Date
    Nov 2010
    Posts
    19
    ye to galt hy

  7. #7
    Administrator Xpert's Avatar
    Join Date
    May 2010
    Location
    Jhelum
    Posts
    6,239
    galat hai tu bhai app is ko thake ker den

  8. #8
    techaholic
    Guest
    everyone shud instead thank him for uploading it
    and jisko lagta hai k kuch ghalat hai either he shud ammend it himself or shud make it right for him [acha hai u will get extra marks for correction while rest nerds will get poor so gud for u]

    thank u xpert

  9. #9

  10. #10
    Junior Member
    Join Date
    Oct 2010
    Posts
    3

    cs-201 Assignment 5 Soloution

    /* ID: MC100402622.
    Name: M.MOHSIN CH.
    */


    #include <iostream.h>
    #include <string.h>
    #include <ctype.h>
    #include <stdlib.h>
    #include <fstream.h>
    using namespace std;


    class crectangle
    {
    private:
    int itop;
    int iright;
    int ibot;
    int ileft;

    public:

    static int irefcount;
    // default constructor is declared below.
    crectangle ();
    // copy constructor is declared below.
    crectangle (crectangle &, crectangle *);
    // destructor is declared below.
    ~crectangle ();

    // methods are declared below.
    int getrectanglearea (crectangle &);
    void getitop();
    void getiright();
    void getibot();
    void getileft();
    void getirefcount();
    void setmembrs (int,int,int,int);
    void setitop(int);
    void setiright(int);
    void setibot(int);
    void setileft(int);

    };

    // Methods, constructor and destructor are defined below.

    // crectangle () is defined below.
    crectangle::crectangle ()
    {
    itop=0;
    iright=0;
    ibot=0;
    ileft=0;
    irefcount++;
    }// crectangle ()'s defination ends here.

    // crectangle (crectangle &) is defined below.
    crectangle::crectangle(crectangle &a, crectangle *pointer)
    {
    pointer=new crectangle;
    pointer->itop=a.itop;
    pointer->iright=a.iright;
    pointer->ibot=a.ibot;
    pointer->ileft=a.ileft;
    irefcount++;
    }

    // destructor ~crectangle () is defined below.
    crectangle::~crectangle()
    {
    irefcount--;
    }// ~crectangle ()'s defination ends here.

    // getitop () is defined below.
    void crectangle:: getitop()
    {
    cout<<endl<<"Value of ITop is: \t"<<itop<<endl;
    }// getitop ()'s defination ends here.

    // getiright() is defined here.
    void crectangle:: getiright()
    {
    cout<<endl<<"Value of IRight is: \t"<<iright<<endl;
    }// getiright()'s defination ends here.

    // getibot () is defined below.
    void crectangle:: getibot()
    {
    cout<<endl<<"Value of IBot is: \t"<<ibot<<endl;
    }// getibot ()'s defination ends here.

    // getileft () is defined below.
    void crectangle:: getileft()
    {
    cout<<endl<<"Value of ILeft is: \t"<<ileft<<endl;
    }// getileft ()'s defination ends here.

    // getirefcount () is defined here.
    void crectangle:: getirefcount()
    {
    cout<<endl<<"Value of IREfcount is: \t"<<irefcount<<endl;
    }// getirefcount()'s defination ends here.

    // getrectangleare () is defined below.
    int crectangle::getrectanglearea(crectangle &a)
    {
    return (a.itop * a.iright * a.ibot * a.ileft);

    }// getrectanglearea ()'s defination ends here.

    // setmembers (int, int ,int ,int ) is defined below.
    void crectangle:: setmembrs(int a, int b, int c, int d)
    {
    itop=a;
    iright=b;
    ibot=c;
    ileft=d;
    } // setmembers ()'s defination ends here.


    // setitop (int) is defined below.
    void crectangle::setitop(int a)
    {
    itop=a;
    }//setitop (int) ends here.

    // setiright (int) ends here.
    void crectangle:: setiright (int b)
    {
    iright=b;
    }// setiright (int)'s defination ends here.

    // setibot(int) is defined below.
    void crectangle::setibot(int c)
    {
    ibot=c;
    }//setbot (int)'s defination ends here.

    // setileft(int) is defined below.
    void crectangle::setileft(int d)
    {
    ileft=d;
    }// setileft(int)'s defination ends here.



    // Static member of class is intialized here.
    int crectangle::irefcount=0;

    // Main () function starts from here.
    main ()
    {
    int a, b, c, d =0;
    crectangle *pointer;
    crectangle rectangle1, rectangle2;
    a=6;
    b=13;
    c=14;
    d=5;
    cout<<endl;
    rectangle1.setitop(a);
    rectangle1.setiright(b);
    rectangle1.setibot(c);
    rectangle1.setileft(d);
    cout<<"Area of rectangle1 is: \t"<<rectangle1.getrectanglearea(rectangle1)<<endl ;
    a=3;
    b=10;
    c=8;
    d=20;
    rectangle2.setmembrs(a,b,c,d);
    cout<<endl<<"Area of rectangle2 is: \t"<<rectangle1.getrectanglearea(rectangle2)<<endl ;
    cout<<endl<<"The Number of Rectangles is \t"<<crectangle::irefcount<<endl;
    crectangle(rectangle1,pointer);
    cout<<endl<<"After using copy-constructor Number of Rectangles is \t"<<crectangle::irefcount<<endl;
    delete pointer;
    cout<<endl<<"The Number of Rectangles is \t"<<crectangle::irefcount<<endl;

    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need CS201 Assignment No 5 Solution
    By Muhammad Abdullah Khan in forum Assignments & Solutions
    Replies: 14
    Last Post: 07-06-2012, 04:58 PM
  2. Soltution of CS201 5th assignment
    By athar1984 in forum Assignments & Solutions
    Replies: 0
    Last Post: 01-26-2012, 04:25 PM
  3. Solution of CS201 5th assignment
    By gm mughal in forum Mcs
    Replies: 0
    Last Post: 06-30-2011, 12:00 AM
  4. Cs201 assignment 5
    By usman malik in forum Get Solution In 24 Hour
    Replies: 0
    Last Post: 07-13-2010, 06:50 AM
  5. CS201-CS403 Assignment 2 result
    By viki in forum Announcements
    Replies: 0
    Last Post: 05-22-2010, 06:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft