do {
// code
} while(/* condition */);
https://booklified.com/
// Program to add numbers until the user enters zero
#include <stdio.h>
int main() {
double number, sum = 0;
// the body of the loop is executed at least once
do {
printf("Enter a number: ");
scanf("%lf", &number);
sum += number;
}
while(number != 0.0);
printf("Sum = %.2lf",sum);
return 0;
}
while(condition) {
statement(s);
}
//This program stops when a number greater than 10 is printed and prints that, value greater than 10
#include <stdio.h>
main()
{
int a;
do
{
printf("
Enter your value: ");
scanf("%d", &a);
} while (a<10);
printf("Value greater than 10");
}
//While loop, for the largest of two numbers.
#include <stdio.h>
int main(){
int a, b;
printf("Enter Values a and b:
");
scanf("%d %d", &a, &b);
while (a < b){
printf("%d is greater than %d
", b, a);
printf("Enter Values a and b:
");
scanf("%d %d", &a, &b);
}
printf("%d is greater than %d
", a, b);
}
#include <stdio.h>
int main()
{
int j=0;
do
{
printf("Value of variable j is: %d
", j);
j++;
}while (j<=3);
return 0;
}
// Print numbers from 1 to 5
#include <stdio.h>
int main() {
int i = 1;
while (i <= 5) {
printf("%d
", i);
++i;
}
return 0;
}
//the syntax of the while loop statement is: init; while(condition) {statement(s);inc/dec;}
//init=initialization
//inc=increment|incrementation formula is i++ or ++i
//dec=decrement|decrementation formula is i-- or --i
#include<stdio.h>
main()
{
int n=0;
while(n<=10)
{
printf("%d, ",n);
n++;
}
}
do {
// the body of the loop
}
while (testExpression);
while (testExpression) {
// the body of the loop
}
//the syntax of the do-while loop statement is: init; do {statement(s);inc/dec;} while(condition);
//init=initialization
//inc=increment|incrementation formula is i++ or ++i
//dec=decrement|decrementation formula is i-- or --i
#include<stdio.h>
main()
{
int n;
n=5;
do
{
printf("
%d ",n);
n--;
}
while(n>=1);
}
Code Example |
---|
C :: integer in c |
C :: What should main() return in C? |
C :: armstrong in c |
C :: relational operators in c |
C :: compile in c |
C :: functions in c programming |
C :: what is the last character of a string in c |
C :: les fichiers en c |
C :: exponentials in c |
C :: what does packing mean in c |
C :: ansi c read write bmp |
C :: Number 10 |
C :: le reste de division in algorithm c |
C :: String to Integer (atoi) |
C :: How to include multiline conditional inside template literal |
C :: c %d |
C :: uninstall elgg from hostgtor |
C :: windows block application au demarrage regegit |
C :: cmake boilerplate for visual studio c++ project |
C :: man write c |
C :: suma de digitos |
C :: determination data type in c |
C :: analog clock c code for turbo |
C :: c how to include variables of other c file |
C :: iulia vântur |
C :: C How to use enums for flags? |
C :: change variable type in c |
C :: youtube code |
C :: 4k stogram chave |
Dart :: dart get String input from user |