Hello, I was wondering if I had an array of the data type float, is there a way that I could change my entire array to the data type int? It's fine if everything past the decimal point gets chpped off, I'm not trying to round.
thank you
Hello, I was wondering if I had an array of the data type float, is there a way that I could change my entire array to the data type int? It's fine if everything past the decimal point gets chpped off, I'm not trying to round.
thank you
As far as i know....there is no standard way to convert type of arrays....but you can do this
Code:#include<iostream> using namespace std; int main() { float a[]={1.1,2.2}; for(int i=0;i<2;i++) { a[i]=int(a[i]); cout<<a[i]<<" "; } return 0; }
"Service of the poor and destitutes is the service of the God"
Normative Changes to ISO/IEC 9899:1990 in Technical Corrigendum 1
Incompatibilities Between ISO C and ISO C++
dont forget that this is a C boardCode:#include<iostream> using namespace std; int main() { float a[]={1.1,2.2}; for(int i=0;i<2;i++) { a[i]=int(a[i]); cout<<a[i]<<" "; } return 0; }