954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

help fixing my calculator in C

This is the code I wrote for a calculator in C

#include

int main (int argc, char **argv)

{
int i;
int value;
int total;
char operator;

total=atoi(argv[1]);

for(i=2; argc>i+1; i=i+2)
{
operator=argv[i][0];
value=atoi(argv[i+1]);

if(operator=='+')
{
total=total+value;
}
else if(operator=='-')
{
total=total-value;
}
else if(operator=='*')
{
total=total*value;
}
else if(operator=='/')
{
total=total/value;
}

}
fprintf(stdout, "%d\n", total);

return 0;
}

Now I need to make it accept Roman numerals. I know i have to program the atoi function, but I dont know how to do that. It only need to go up to 4999. and when it prints the answer in roman numerals it can print like 456=CCCCLVI.
Can someone please help me? or at least give me a hint so I can do it myself
Thanks

kiki021600
Newbie Poster
6 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You