Welcome to Dream.In.Code
Become a C++ Expert!

Join 136,910 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,735 people online right now. Registration is fast and FREE... Join Now!




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

 
Reply to this topicStart new topic

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

awe
17 Mar, 2008 - 09:17 AM
Post #1

New D.I.C Head
*

Joined: 17 Mar, 2008
Posts: 1

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

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

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

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

factorial(cool.gif; //will output the result of b factorial

return 0;
}


User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Help Me To Discuss About The Class N The Finction Of The Main Function
17 Mar, 2008 - 09:31 AM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,228



Thanked: 40 times
Dream Kudos: 25
My Contributions
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.gif

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

Thanks.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 09:56PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month