Table of Contents
In this tutorial, we will discuss the concept of C programming Language Do-while loop
In this post, we are going to learn how to use the do-while loop in C language
Do-while loop
What is the usage of the do-while loop in C? you can understanding after reading this article .
generally in programming languages, looping statements used in programming language to executes of block of code until the perticular condition is satisfied.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i=1;
do{
printf(“%i”,i);
i++;
}
while(i<=10);
//printf(“Hello world!n”);
return 0;
}
In the program, test expression returns true codes inside the loop body are executes until become condition is false, so output here
Te program displays natural numbars 1 to given number
Program 2
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i=1;
do{
printf(“%in”,i);
i++;
}
while(i>=10);
return 0;
}
When the above code is executed, it produces the following result
#include <iostream> #include <conio.h> using namespace std; int main() { int sum=0; int n; cout << "Enter the number as you wish" << endl; cin>>n; int i=1; do{ sum=sum+i; i++; }while(i<=n); cout<<"The sum of 1 to "<<n<<" : "<<sum; getch(); return 0; }
When the above code is executed, it produces the following result
Enter the number as you wish 100 The sum of 1 to 100: 5050
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.