Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- int main(){
- int i = 0;
- char nome[100];
- float nota1, nota2;
- int qtd;
- float media;
- int result;
- FILE* arquivo = fopen("alunos.txt", "r");
- if(!arquivo) {
- printf("ops arquivo nao criado\n");
- }
- result = fscanf(arquivo, "%d", &qtd);
- if(result == EOF) {
- printf("sem dados pra ser lido\n");
- }
- for(i = 0; i < qtd; i ++) {
- result = fscanf(arquivo, "%s\n%f\n%f", nome, ¬a1, ¬a2);
- media = (nota1+nota2)/2;
- if(media < 7) {
- printf("%s\n", nome);
- }
- }
- fclose(arquivo);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment