help me to discuss about the class n the finction of the main function

help me to discuss about the class n the finction of the main function

Page 1 of 1

1 Replies - 743 Views - Last Post: 17 March 2008 - 10:31 AM Rate Topic: -----

#1 awe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-March 08

help me to discuss about the class n the finction of the main function

Post icon  Posted 17 March 2008 - 10:17 AM

A machine with 32-bit integers can represent integers in the range of approximately 2 billion to +2 billion. This fixed-size restriction is rarely troublesome, but there are applications in which we would like to be able to use a much wider range of integers, such as factorial. This is what C++ was built to do, namely, create powerful new data types.
Create class HugeInt that is capable of representing positive (non-negative) 30-digit decimal values (this will be able to represent values from 0 to 1030). The 30-digit number can be represented internally as array of integer whereby each digit takes values from zero to nine. The class must have conversion constructor that convert int or char value to HugeInt. Then overload the following operators
a. Stream insertion (<<) and extraction (>>) operators.
b. Arithmetic operators (+,-,/,*). Each operation must also support operation with mix operands (integer and HugeInt objects).
c. Relational operators (==,<=,>=,!=). Each operation must also support operation with mix operands (integer and HugeInt objects).
d. Define a function factorial(X) that calculate factorial of X, whereby X is a HugeInt object.



int main()
{
HugeInt a; //HugeInt object initialized to zero
HugeInt b(12345);
HugeInt c(“100200101002005550”);
HugeInt result;
cin >> a;
result = a+b;
cout << a << “+” << b << “ = “ << result << endl;
result = c – b;
cout << result << endl;
result = c / b;
cout << result << endl;
result = c * b;
cout << result << endl;
if (a == B)
cout << “Equal” << endl;
else
cout << “Not Equal” << endl;

if (a >= B)
cout << “Greater” << endl;
else
cout << “Less” << endl;

if (a <= B)
cout << “Less” << endl;
else
cout << “Greater” << endl;

if (a != B)
cout << “Not Equal” << endl;
else
cout << “Equal” << endl;

factorial(B); //will output the result of b factorial

return 0;
}

Is This A Good Question/Topic? 0
  • +

Replies To: help me to discuss about the class n the finction of the main function

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: help me to discuss about the class n the finction of the main function

Posted 17 March 2008 - 10:31 AM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

you have provided a driver program (which I suppose was provided to you)...can you please post your attempt to define the class?

Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1