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
Are c and c++ the same?
explain what is fifo?
What is c value paradox explain?
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.
What is oops c?
Is fortran still used in 2018?
What standard functions are available to manipulate strings?
What are the modifiers available in c programming language?
string reverse using recursion
What is difference between structure and union?
What is a sequential access file?
What is LINKED LIST? How can you access the last element in a linked list?
In a byte, what is the maximum decimal number that you can accommodate?
using for loop sum 2 number of any 4 digit number in c language
write a program to print largest number of each row of a 2D array