# decimals in calculator

This is a discussion on decimals in calculator within the C++ Programming forums, part of the General Programming Boards category; how do you make it posible that the user can input a decimal? i heard about floats , but cant ...

1. ## decimals in calculator

how do you make it posible that the user can input a decimal?
i heard about floats , but cant find how-to
for example
Code:
```inline void vermenigvuldigen()
{

int x;
int y;
C.I = 8;
setcolor(C.I);

cout<<"schrijf 2 getallen voor te vermenigvuldigen: ";
cin>>x>>y;
cin.ignore();
cout<<"het produkt van de 2 getallen is ";
C.I = 10;
setcolor(C.I);
cout<<x*y<<"\n";
int input;
C.I = 4;
setcolor(C.I);
cout<<"1.nog eens\n";
cout<<"3.sluiten\n";
cout<<"selectie";
cin>>input;
switch (input) {
case 1:
system("cls");
vermenigvuldigen();
case 2 :
system("cls");
main();
case 3 :
system("cls");
exit ( EXIT_FAILURE );//sluit af
default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
vermenigvuldigen();
}
}```

2. You can use data type of 'double' or 'float'.

Declare as follows:

Code:
`float hello1;`
Code:
`double hello1;`

3. how do you put them in the code?

4. Code:
```switch (input) {
case 1:
system("cls");
vermenigvuldigen();
case 2 :
system("cls");
main();
case 3 :
system("cls");
exit ( EXIT_FAILURE );//sluit af
default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
vermenigvuldigen();
}```
The parts in red are extremely poor design. You shouldn't be using recursion for a problem that calls for iteration. Rather than calling vermenigvuldigen, you should wrap the entire body of the function within a loop.

The part in blue is illegal. Main cannot be called recursively in C++. You're relying on a quirk of your compiler. Even if it were legal, it would exhibit the same poor design as the parts in red.

5. Have you considered learning C++ from the basics?

By the way, it looks like you may have a recursive call to the global main() function, which is not allowed.

6. just answer on my question
i m just beginning and follewing the tutorials here
but wants to experiment with a calculator

7. btw : IT'S JUST A PART OF THE CODE

8. Get an attitude adjustment and try again.