What is output of the following: 
 
                   k = 0;
                   m = 0;
                   for  (p = 0;  p < 10;  p = p + k) {
                      k = k + 1;
                      m = m + p;
                      printf("%d %d %d\n", p, k, m);
                   }        
        1
                    
                            
                                        2011-06-20T12:10:54-0400
                    
                                                    
                                1st loop,&  p=p+k=0+0=0<10:
   k=k+1=0+1=1 m=m+p=0+0=0
2nd loop, p=p+k=0+1=1<10:
   k=k+1=1+1=2 m=m+p=0+1=1
3rd loop, p=p+k=1+2=3<10:
   k=k+1=2+1=3 m=m+p=1+3=4
4th loop, p=p+k=3+3=6<10:
   k=k+1=3+1=4 m=m+p=4+6=10
5th loop: p=p+k=6+4=10, that`s all, condition is not satisfied, so output is
0&  1 &  0
1&  2   1
3&  3   4
6&  4   10                            
                                                 
                 
                    
        
            
                Need a fast expert's response?
                Submit order
                and get a quick answer at the best price
                for any assignment or question with DETAILED EXPLANATIONS!
             
            
            
         
            
        Learn more about our help with Assignments: 
C++     
 
                        
Comments