Created
December 14, 2018 22:35
-
-
Save ivanelson/b0487a7ff5abd8f68e44acde2f5a0f22 to your computer and use it in GitHub Desktop.
media com do-while in "C"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
void main() { | |
float nota, soma = 0, media; | |
int resp, contador = 0; | |
do { | |
printf("Digita a nota: "); | |
scanf("%f", ¬a); | |
soma = soma + nota; | |
printf("\nDigite 1 para continuar ou digite outra tecla para finalizar...: "); | |
scanf("%d", &resp); | |
contador++; // o mesmo que contador = contador + 1 | |
} while (resp == 1); | |
media = soma / contador; | |
printf("\nA media da turma eh %.2f \n", media); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment