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

Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me

1946


plz let me know how to become a telecom protocol tester. thank you.

2189


Explain the ternary tree?

1021


What are the types of pointers?

1109


Write a program for finding factorial of a number.

1085


How can I call fortran?

1039


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1084


using for loop sum 2 number of any 4 digit number in c language

2330


What will be your course of action for a push operation?

1109


What is logical error?

1116


Can you please compare array with pointer?

1079


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

1065


Can main () be called recursively?

1115


What are the preprocessor categories?

1055


Can we declare variable anywhere in c?

966