Discussion in 'C++' started by ckmelissa86, Oct 10, 2007.

1. ### ckmelissa86New Member

Joined:
Oct 10, 2007
Messages:
4
0
Trophy Points:
0
hi,i'm Melissa from Malaysia.. I'm a Uni student and i got problem with link list programming.Hope that you can help me to solve it

Well, now i need to write a program which using link list to make a calculator.

The concept which i plan to do is that.. 3 digit save in 1 node in reverse order.. then when we need to do some math operation like addition or subtraction.. the operation if execute in the reverse order..

Hope you guys will help me .. and hope i can get ur reply soon...

Take care and all the Best

Best regard:
Melissa

2. ### seegunaNew Member

Joined:
Jun 20, 2007
Messages:
31
0
Trophy Points:
0
Occupation:
Technical Consultant
Location:
Chennai
Post ur trying code so that i will rectify ur problem

3. ### ckmelissa86New Member

Joined:
Oct 10, 2007
Messages:
4
0
Trophy Points:
0
Code:
```//libraries
#include<iostream.h>
#include<conio.h>

void main()
{ //declare the variables
int i[3][10];
char c[2][10];
int bil;

//promt the user to enter the number
cout<<"Masukkan bilangan digit : ";
cin>>bil;

//loop for enter 2 difference number
for(int y=0;y<2;y++)
{
//loop for enter the number
for (int x=bil-1;x>=0;x--)
{
cin>>c[y][x];
}
}

//loop for convert the 2 numbers into int
for(int y=0;y<2;y++)
{
for (int x=bil-1;x>=0;x--)
{
i[y][x]=(int)c[y][x];
}
}

//Display result
for(int y=0;y<2;y++)
{
for (int x=bil-1;x>=0;x--)
{
cout<<i[y][x]<<"   ";

}  cout<<endl;
}

//this part not understand
int b=0;
for (int x=bil-1;x>=0;x--)
{
i[2][x]=i[0][x]+i[1][x]+b;
if(i[2][x]>10)
{
i[2][x]=i[2][x]-10;
b=1;
}
else
b=0;
}

//Display result
for (int x=0;x<bil;x++)
{
cout<<i[2][x]<<"   ";

}

getch();
}
```
this is the rough coding i did.. but this is only for addition..i am still trying to do for subtraction

Thx for helping

Last edited by a moderator: Oct 18, 2007
4. ### DaWeiNew Member

Joined:
Dec 6, 2006
Messages:
835
5
Trophy Points:
0
Occupation:
Semi-retired EE
Location:
Texan now in Central NY
http://www.daweidesigns.com
Read the "Before you make a query" thread, particularly with regard to the use of code tags.

5. ### seegunaNew Member

Joined:
Jun 20, 2007
Messages:
31
0
Trophy Points:
0
Occupation:
Technical Consultant
Location:
Chennai
hi,
I just go thru ur coding, What u did is "Read some characters in an array, Convert that character array as Integer array and finally u add the integers values present in it"....
i..e very basic program

Where is ur Linked list problem?
I think that u sent something else.....

If u clearly explain ur problem means i m ready to solve it..............