How can I use the first digit of the number which has 2 or more digits? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I use the first digit of the number which has 2 or more digits?

For example I have the number 324 and I want to use the second digit of that(number 2)

7th Nov 2019, 4:20 PM
Mohammad Amin Abbasfar
8 Answers
+ 2
First of all, what language are you using, please include it in the tags intead of '.'
7th Nov 2019, 4:28 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
Sorry I forgot it I am using c++
7th Nov 2019, 4:30 PM
Mohammad Amin Abbasfar
7th Nov 2019, 4:36 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
Thank you for the other question But in this I want it as an int
7th Nov 2019, 4:43 PM
Mohammad Amin Abbasfar
7th Nov 2019, 5:33 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
Your question asks for how to get the first digit of a number. But in your Description you wrote that you want the second digit. Which one are you asking for? or maybe you want to use any of the digit at random position?
7th Nov 2019, 5:51 PM
Ipang
+ 1
Thank you
8th Nov 2019, 2:58 AM
Mohammad Amin Abbasfar
0
better choise is to read the number as a string. string nb[10]; cout << “put some number”; cin >> nb; cout << nb[1]; /*index 1 it mean the second number.*/
9th Nov 2019, 11:24 AM
El Mehdi El Ouakifi