+ 1

What's the problem??

double prices[] = {6.99, 8.5, 42.9, 105.4, 42, 98.1, 2.39, 1.99, 68.76, 9.99, 33.67, 105, 99, 67, 24.56, 0.2, 59.87, 77.2}; auto total=0; for(int x = 0;x<18;x++){ total += prices[x]; } cout << total << endl;

5th Feb 2024, 5:55 AM
Mayank Pal
Mayank Pal - avatar
6 Respostas
+ 5
Mayank Pal , Change this, auto total=0; to this. auto total=0.0; And, still, please add a tag for the language. Your question appears in a list of just the question headers. It makes it easier for the people who help to know which questions they want to help with if they can see the language without opening it.
5th Feb 2024, 7:04 AM
Rain
Rain - avatar
+ 4
Please add a tag for the language, and please give your whole code, preferably as a link rather than a paste. If that's C, it's missing main etc.
5th Feb 2024, 6:56 AM
Rain
Rain - avatar
+ 3
Thanks a lot. Will never commit the mistake you mentioned 😊
5th Feb 2024, 5:17 PM
Mayank Pal
Mayank Pal - avatar
+ 2
We'll, that's c++
5th Feb 2024, 6:57 AM
Mayank Pal
Mayank Pal - avatar
+ 1
#include <iostream> using namespace std; int main() { double prices[] = {6.99, 8.5, 42.9, 105.4, 42, 98.1, 2.39, 1.99, 68.76, 9.99, 33.67, 105, 99, 67, 24.56, 0.2, 59.87, 77.2}; auto total=0; for(int x = 0;x<18;x++){ total += prices[x]; } cout << total << endl; return 0; }
5th Feb 2024, 7:00 AM
Mayank Pal
Mayank Pal - avatar
0
How do i get <button to actually do something
7th Feb 2024, 1:15 AM
Cayden Sayre