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...

 Illustrate it 
 summing the series 2+4+6+......to n terms using 
(i) while loop (ii) do-while loop

Answer Posted / srujitha

// while loop
int main()
{
int n = 3,sum = 0,i = 2, count = 0;

while(n > count)
{
sum = sum + i;
i = i+2;
count++;
}
printf("SUM = %d ",sum);
}

// do while loop

int main()
{
int n = 3,sum = 0,i = 2, count = 0;


do
{
sum = sum + i;
i = i+2;
count++;
}
while(n > count);
printf("SUM = %d ",sum);
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In a switch statement, explain what will happen if a break statement is omitted?

1008


What is huge pointer in c?

1035


What is uint8 in c?

1062


Why c is a procedural language?

1016


Does c have function or method?

949


What are different storage class specifiers in c?

1055


Why is c called "mother" language?

1238


Why do some versions of toupper act strangely if given an upper-case letter?

1046


What is the purpose of main() function?

1194


What is a structural principle?

1102


What is the difference between declaring a variable by constant keyword and #define ing that variable?

3297


What do you mean by invalid pointer arithmetic?

1015


which type of aspect you want from the student.

2130


What is meant by errors and debugging?

1066


A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile

1059