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?

29th Nov 2020, 11:43 PM
Thunder Jack
Thunder Jack - avatar
3 Answers
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
30th Nov 2020, 12:03 AM
Angelo
Angelo - avatar
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.
30th Nov 2020, 12:49 AM
Davide
Davide - avatar
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/
1st Dec 2020, 2:57 AM
AjayGohil