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

Page 1 of 1

1 Replies - 1529 Views - Last Post: 17 March 2008 - 10:31 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=46519&amp;s=ba9eb0b5e19ac74d9977aff49d762ae1&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 awe

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

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

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 ==
cout << “Equal” << endl;
else
cout << “Not Equal” << endl;

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

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

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

factorial(; //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

• g+ + -o drink whiskey.cpp

Reputation: 250
• Posts: 13,507
• 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.