Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Input/Output statements
  5. Looping statements
  6. do while loop

do while loop

Syntax

do
{
   statement
}while(expression);

Flow chart

Example

Sum of the series

// Sum of the series
#include<stdio.h>
int main()
{
	int terms, sum=0, c=0;
	printf("enter number of terms \t");
	scanf("%d",&terms);
	do
	{
		sum = sum + c;
		c=c+1;
	}while(c <= terms);
	printf("Sum of series is %d",sum);
	return 0;
}

Output

enter number of terms   5
Sum of series is 15

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments