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

Are c and c++ the same?

1001


explain what is fifo?

1022


What is c value paradox explain?

1014


Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.

1945


What is oops c?

1110


Is fortran still used in 2018?

983


What standard functions are available to manipulate strings?

1074


What are the modifiers available in c programming language?

1171


string reverse using recursion

2368


What is difference between structure and union?

1075


What is a sequential access file?

1089


What is LINKED LIST? How can you access the last element in a linked list?

1014


In a byte, what is the maximum decimal number that you can accommodate?

1067


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

2252


write a program to print largest number of each row of a 2D array

2267