“zrobić, gdy pętla c” Kod odpowiedzi

do ... podczas pętli 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

Podczas pętli 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 podczas pętli

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

C do ... podczas pętli

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

Odpowiedzi podobne do “zrobić, gdy pętla c”

Pytania podobne do “zrobić, gdy pętla c”

Więcej pokrewnych odpowiedzi na “zrobić, gdy pętla c” w C++

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu