“Mientras que el bucle C” Código de respuesta

hacer ... mientras bucle C

// 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;
}
SAMER SAEID

Mientras que el bucle C

// Print numbers from 1 to 5

#include <stdio.h>
int main() {
  int i = 1;
    
  while (i <= 5) {
    printf("%d\n", i);
    ++i;
  }

  return 0;
}
SAMER SAEID

C While Loop

while (testExpression) {
  // the body of the loop 
}
SAMER SAEID

C hacer ... mientras bucle

do {
  // the body of the loop
}
while (testExpression);
SAMER SAEID

Respuestas similares a “Mientras que el bucle C”

Preguntas similares a “Mientras que el bucle C”

Más respuestas relacionadas con “Mientras que el bucle C” en C

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código