This is the code I wrote for a calculator in C
#include <stdio.h>
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