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
Printable View
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;
}
dont forget that this is a C board :)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;
}