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
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
plz let me know how to become a telecom protocol tester. thank you.
Explain the ternary tree?
What are the types of pointers?
Write a program for finding factorial of a number.
How can I call fortran?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
using for loop sum 2 number of any 4 digit number in c language
What will be your course of action for a push operation?
What is logical error?
Can you please compare array with pointer?
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
Can main () be called recursively?
What are the preprocessor categories?
Can we declare variable anywhere in c?