I must make a program (using functions) which will enter the number (integer) desired on the screen and this converts it into Roman numerals. What happens is that the program cannot be executed due to these errors:
I am aware that I have not yet called the functions, but I see it as unnecessary at the moment since without even calling them, it already gives me an error and I would like to understand the reason for the problems that arose, for which I would greatly appreciate if you could explain it to me , the code is the following:
#include <iostream>
using namespace std;
int numero;
int unidades (int){
unidades = numero % 10; // 1
numero /= 10; // 389
switch(unidades){
case 1: cout<<"I";break;
case 2: cout<<"II";break;
case 3: cout<<"III";break;
case 4: cout<<"IV";break;
case 5: cout<<"V";break;
case 6: cout<<"VI";break;
case 7: cout<<"VII";break;
case 8: cout<<"VIII";break;
case 9: cout<<"IX";break;
}
}
int decenas (int){
decenas = numero % 10; // 9
numero /= 10; // 38
switch(decenas){
case 1: cout<<"X";break;
case 2: cout<<"XX";break;
case 3: cout<<"XXX";break;
case 4: cout<<"XL";break;
case 5: cout<<"L";break;
case 6: cout<<"LX";break;
case 7: cout<<"LXX";break;
case 8: cout<<"LXXX";break;
case 9: cout<<"XC";break;
}
}
int centenas (int){
centenas = numero % 10; // 8
numero /= 10; // 3
switch(centenas){
case 1: cout<<"C";break;
case 2: cout<<"CC";break;
case 3: cout<<"CCC";break;
case 4: cout<<"CD";break;
case 5: cout<<"D";break;
case 6: cout<<"DC";break;
case 7: cout<<"DCC";break;
case 8: cout<<"DCCC";break;
case 9: cout<<"CM";break;
}
}
int millar (int){
millar = numero; // 3
switch(millar){
case 1: cout<<"M";break;
case 2: cout<<"MM";break;
case 3: cout<<"MMM";break;
}
}
int main (){
int numero;
cout<<"Ingrese un numero entero para convertilo en romano: "<<endl;
cin>>numero; // 3891
return 0;
}
Your error is a bit absurd but very easy to understand:
int(int)
.int(*)(int)
.In all your functions, in the first line you use the function name as if it were a variable:
Surely you wanted to declare a variable instead of using the function name:
And you probably wanted to use a parameter in each function instead of using a global variable: