0
Can not troubleshoot what the problem is
Here is my code for calculating sum of first 100 odd numbers, #include<iostream> #include<cmath> using namespace std; int main() { int i(1),a(0),s(1); cin>>a>>s; while(i<=100) { a+=s; s+=2; i++; } cout<<"The sum is "<<a<<endl; return 0; } This C++ code doesnt given any output and i cant spot the mistake.Any help would be appreciated.
2 Réponses
+ 1
replace the while condition with
while(i<=100)
0
thank u sir have a good day.Now its working