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
Differentiate between functions getch() and getche().
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
What does malloc () calloc () realloc () free () do?
What is call by reference in functions?
Why & is used in scanf in c?
explain what are actual arguments?
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
Is that possible to store 32768 in an int data type variable?
What does 3 periods mean in texting?
Explain the difference between ++u and u++?
Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?
How main function is called in c?
What is a void * in c?
Which of the following operators is incorrect and why? ( >=, <=, <>, ==)
Suggesting that there can be 62 seconds in a minute?