0
float array error
#include<iostream> using namespace std; int main() { float i,n, sum=0.0; cout<<"calculating of total expenditure list"<<endl; cout<<"enter the number of total things you bought: "<<endl; cin>>n; float money[n]; for(i=1;i<=n;i++) { cout<<i<<" no product cost :"<<endl; cin>>money[i]; sum += money[i]; } cout<<"total money used: "<< sum<<" taka"<<endl; return 0; } it doesn't run using float, but runs using int.
10 Answers
+ 1
You can too use the youtube video for you error.just mention the line in which the problem is. We all are going to help you.
Sololearn community teamđ€
+ 1
There is no float value. Where do you want to work with float values, with which and from where are they coming from?
+ 1
You are mixing too many things within your code. i is declared as float too, but actually assigned with integer values and used as integer. Nothing can work with that code! Just read the compiler messages...
+ 1
View this as simple code taking a float 3 times into an array and sum it up. No error handling.
https://code.sololearn.com/c13n5dJi0fuP/?ref=app
+ 1
An array is a kind of a list and I did not use a type "List" here, it is just the variable name of the array...
0
In this program i can't use float anywhere. It only runs through int data type.
0
How can I use float array ?
0
You have no float numbers to store! This is what you have to fix first.
0
I am taking user input. Can i take 1.5 in int array?
0
Thank you. But you have used list here. Is it possible to do without list?