Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Determine the code below, tell me exactly how many times is
the operation sum++ performed ?

for ( i = 0; i < 100; i++ )
for ( j = 100; j > 100 - i; j--)
sum++;

Answer Posted / lnk

Its quite simple to analyse ...

LOOP i=0: i=0
then enters loop j=o: but it false that always J>100-i;

i.e.., i=0;j=100; 100- i-> 100
so always 100 is not greater than 100

than it comes out no sum++;
Loop i=1; ; j =100 only now 100 - i =99 so j>100 -i
(100>99)
then sum++ is executed ;


i= 1 j=100 j > 100 - i j=99 ;sum ++
i=2 j =99 j> 100 - i j =98 ; sum ++

i=50 j=51 j>100-50 true ( 51>50 ) ; sum++ j=50
i=51 j= 50 j>100-51 true(50>49 ) so no sum++


i = 99 j=2 j>100-i true (2>1) sum ++

so sum++ would be executed 99 times

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is python a c language?

1021


difference between native and cross compilers

2141


explain what is a newline escape sequence?

1100


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

1289


What is the difference between constant pointer and constant variable?

1236


how to build a exercise findig min number of e heap with list imlemented?

2079


What do you mean by recursion in c?

1119


What is array of structure in c programming?

1295


Write a function that will take in a phone number and output all possible alphabetical combinations

1058


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

3269


The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

1260


What is a static variable in c?

1138


How macro execution is faster than function ?

1205


How can this be legal c?

1095


What is difference between union and structure in c?

1178