ricop522

Untitled

Jul 13th, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4.  
  5. int main(){
  6.     int i = 0;
  7.     char nome[100];
  8.     float nota1, nota2;
  9.     int qtd;
  10.     float media;
  11.     int result;
  12.     FILE* arquivo = fopen("alunos.txt", "r");
  13.     if(!arquivo) {
  14.         printf("ops arquivo nao criado\n");
  15.     }
  16.     result = fscanf(arquivo, "%d", &qtd);
  17.     if(result == EOF) {
  18.         printf("sem dados pra ser lido\n");
  19.     }
  20.     for(i = 0; i < qtd; i ++) {
  21.         result = fscanf(arquivo, "%s\n%f\n%f", nome, &nota1, &nota2);
  22.         media = (nota1+nota2)/2;
  23.         if(media < 7) {
  24.             printf("%s\n", nome);
  25.         }
  26.     }
  27.  
  28.     fclose(arquivo);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment