Results 1 to 3 of 3

Thread: C++ Experts

  1. #1
    Omer27's Avatar
    Omer27 is offline Advance Member
    Last Online
    30th January 2024 @ 04:01 PM
    Join Date
    27 Jan 2009
    Age
    31
    Posts
    1,725
    Threads
    72
    Credits
    1,374
    Thanked
    66

    Default C++ Experts

    Mujhe is Program ki Missing Function Bodies Chahye.
    Comments Ke Mutabiq.
    Please Koi Help Kare.
    Mujhe Ye Aaj Raat Tak Chahye Lazmi.




    #include <iostream>
    #include <sstream>
    using namespace std;
    class Fraction
    {
    int *numerator, *denominator;
    public:
    Fraction(int num=0, int den=1)
    {
    //dynamically declare numerator and denominator, initialize numerator to num and
    //denominator to den
    }
    void setNumerator(int num)
    {
    //assign num to numerator
    }
    void setDenominator(int den)
    {
    //assign den to denominator
    }
    void setFraction(int num, int den)
    {
    //assign num to numerator and den to denominator
    }
    int getNumerator()
    {
    //return numerator's value
    }
    int getDenominator()
    {
    //return denominator's value
    }
    long double getValue()
    {
    //divide numerator by denominator and return the answer as long double
    //hint: use type casting
    }
    void simplify()
    {
    //simplify the fraction. e.g. 21/12 = 7/4, 25/5 = 5/1, 24/44 = 6/11,
    //10/15 = 2/3, etc
    }
    Fraction add(Fraction f)
    {
    //add f to the current fraction(through which the function is being called)
    //and return the result as a fraction
    //e.g. Fraction f1(2,3), f2(4,5); f1.add(f2); here f1 is the current fraction
    //and f2 will be mapped onto the input parameter 'f'
    //you'll have to add two fractions, the current one and f like fractions are added
    //for hint, see multiply and divide below
    }
    Fraction subtract(Fraction f)
    {
    //subtract f from current fraction and return the result as a fraction. a clever
    //solution will be to use add function for subtraction
    //as a-b = a+(-b). for hint, see the divide function below.
    }
    Fraction multiply(Fraction f)
    {
    Fraction temp(*numerator * f.getNumerator(), *denominator * f.getDenominator());
    return temp;
    //*numerator and *denominator belong to current fraction and f.getNumerator() and
    //f.getDenominator() will return f's numerator and denominator respectively
    //the above can also be achieved by doing the following statement. its known as
    //returning temporary unnamed object
    //return (Fraction(*numerator * f.getNumerator(), *denominator * f.getDenominator()));
    }
    Fraction divide(Fraction f)
    {
    Fraction temp(f.getDenominator(), f.getNumerator());
    //temp will be equal to f's reciprocal
    return multiply(temp); //because (2/3)/(4/5) = (2/3)*(5/2)
    }
    bool isEqual(Fraction f)
    {
    return getValue() == f.getValue();
    }
    bool isLessThan(Fraction f)
    {
    return getValue() < f.getValue();
    }
    bool isLessThanOrEqual(Fraction f)
    {
    return getValue() <= f.getValue();
    }
    bool isGreaterThan(Fraction f)
    {
    return getValue() > f.getValue();
    }
    bool isGreaterThanOrEqual(Fraction f)
    {
    return getValue() >= f.getValue();
    }
    bool isNotEqual(Fraction f)
    {
    return getValue() != f.getValue();
    }
    string toString()
    {
    if(*denominator==0) return "UNDEFINED";
    if(*numerator==0) return "0";
    ostringstream output;
    if(*denominator==1) output<<*numerator;
    else output<<*numerator<<'/'<<*denominator;
    return output.str();
    }
    void display()
    {
    cout<<toString();
    }
    };

  2. #2
    Omer27's Avatar
    Omer27 is offline Advance Member
    Last Online
    30th January 2024 @ 04:01 PM
    Join Date
    27 Jan 2009
    Age
    31
    Posts
    1,725
    Threads
    72
    Credits
    1,374
    Thanked
    66

    Default

    Koi To Help Kare

  3. #3
    Omer27's Avatar
    Omer27 is offline Advance Member
    Last Online
    30th January 2024 @ 04:01 PM
    Join Date
    27 Jan 2009
    Age
    31
    Posts
    1,725
    Threads
    72
    Credits
    1,374
    Thanked
    66

    Default

    Kia Kisi Ko Nahi Aata

Similar Threads

  1. flash problem jaldi experts please mobile experts kahan hein
    By lovtam in forum Mobile phones problems and Help Zone
    Replies: 2
    Last Post: 19th September 2012, 11:09 AM
  2. it experts and software experts help kr
    By djlink in forum Mobile phones problems and Help Zone
    Replies: 1
    Last Post: 19th January 2011, 08:16 PM
  3. Replies: 6
    Last Post: 3rd September 2009, 06:54 AM
  4. Experts And VB Experts plz plz click here
    By ghouri67 in forum Ask an Expert
    Replies: 1
    Last Post: 23rd December 2007, 01:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •