programs asked 1.to inverse the content of a arrray.don't use tmp variables 2 . to reverse a sentence. 3.to find the missing no : in a array of size 100. which have numbers from 1-101 written randomly
1. the key here is to know how to flip 2 array cells without using a temp. This how I would it, there are probably other ways. for(int i=0;i 'cde acb' or 'abc cde' => ' edc cba' ? the former is of course simpler, you just iterate of the pointer and feed it to another pointer. 3. int sigma= n*(1+ n +1)/2 ;// sum of arithmetic series int missing_sigma = 0; for(int i=0;i < n;i++); missing_sigma +=array[i]; return sigma - sigma
had a little mistake there, its "return sigma - missing_sigma"
18 Dec 2009