+ 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.
7 Réponses
+ 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
+ 1
ok ty Jayakrishna🇮🇳
0
Ex: 1.2 to what?
0
Just cast to int like
int x = (int) random(n) ;
double n = 1.2;
cout<< (int)n<<endl;
0
no the number will be given through cin>> Jayakrishna🇮🇳
0
What ever way, read the number and convert to int.
double n;
cin>>n;
int m = (int) n;
0
You're welcome..