0
Please in C how can I take the user input (number) and convert it to decimal, for a calculator making?
Please in C how can I take the user input (number) and convert it to decimal, for a calculator making?
3 Réponses
0
It depends on whitch base you suppose the user will input the number.
Just pretend he will use decimal, as nobody will enter e hex or binary when asked for a number
0
If the user enters an hexadecimal number, you can use %x
http://www.cplusplus.com/reference/cstdio/printf/
https://code.sololearn.com/c8XjpaJKYKog/?ref=app
Otherwise you need to create a function that converts the number.
0
Hello,
For user input use following code:
double x;
cout << "Type a number: "; // Type a number and press enter
cin >> x;
conversion depended on data type of variable.
For Conversion refer following side:
https://www.programiz.com/c-programming/examples/binary-decimal-convert
https://www.geeksforgeeks.org/convert-base-decimal-vice-versa/