how to remove decimal or non integer numbers? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

how to remove decimal or non integer numbers?

need whole numbers 1,2,3,4 ,5 ... i need both a way to separate decimals alone . and one that can separate decimals and - values. thank you in advance.

11th May 2022, 8:51 PM
learner
learner - avatar
7 Respostas
+ 1
JayakrishnašŸ‡®šŸ‡³ i want to use only integer values for example i use this i will get a number random (n) i will divide that number in half some of the results will be in decimal i dont want those
11th May 2022, 9:15 PM
learner
learner - avatar
11th May 2022, 9:26 PM
learner
learner - avatar
0
Ex: 1.2 to what?
11th May 2022, 9:05 PM
Jayakrishna šŸ‡®šŸ‡³
0
Just cast to int like int x = (int) random(n) ; double n = 1.2; cout<< (int)n<<endl;
11th May 2022, 9:18 PM
Jayakrishna šŸ‡®šŸ‡³
0
no the number will be given through cin>> JayakrishnašŸ‡®šŸ‡³
11th May 2022, 9:19 PM
learner
learner - avatar
0
What ever way, read the number and convert to int. double n; cin>>n; int m = (int) n;
11th May 2022, 9:22 PM
Jayakrishna šŸ‡®šŸ‡³
0
You're welcome..
11th May 2022, 9:26 PM
Jayakrishna šŸ‡®šŸ‡³