Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
2,531 views
int i = 0 ; 
int sum = 0 ;

 while(i<100)
{    
     sum = sum + i ;
     i++;   
}
cout<<sum  ; 
in Beginners by | 2,531 views

2 Answers

1 like 0 dislike
Best answer
HERE SUM WILL BE 0+1+2+3+.....+99  IS AP SUM ,

here a=0 and Tn=99;

AND AP sum= (n/2)(a+Tn);

Answer would be sum=(100/2) (0+99) = 50*99 =4950.
by
selected by
0 0
Wow , great explanation ! Awesome ! :-)
1 like 0 dislike
Its  an AP so Sum= 5050
by
0 0
I think your answer is wrong as 100 is not included in the sum...