+ 1
In c++ when you want to use the sum value, you should put int sum = 0; first or just int sum;?
Sum in C++
2 ответов
+ 1
I do something like that.
int sum=0;
for(int i=0;i<SomeMaxValueOfArray;i++){
sum+=Array_Used[i];
}
cout<<sum<<endl;
+ 1
firstly if you want to find sum of 2 or more value , it not important to name them sum you can name that var anythinge (eg.x,ab,a,s and etc) , and if you want to assign value for that sum var you have to use '=' sign (eg. int sum=10)