0

Can someone explain me how the output is coming to 1890?

#include<iostream> using namespace std; float value = 900; void local (int T) { int result = 0; for ( int I=0; I<T; I++) result+=I; cout << value + result ; } int main() { local(45); return 0; }

30th Nov 2019, 3:40 PM
Dipanjan Basu
Dipanjan Basu - avatar
2 Réponses
+ 1
Thanks for answering, Not getting how is 990 coming ( I am new to functions) all I understood is float value = 900 is global my question is the loop
30th Nov 2019, 4:03 PM
Dipanjan Basu
Dipanjan Basu - avatar
+ 1
Dipanjan Basu , first the loop calculates the following sum 0+1+2+3+...+44 => 990. Next adding 900 and display it 990 + 900 => 1890.
30th Nov 2019, 4:05 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar