Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 0.69 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. int main ( ) {                          
  5.    float nota, soma, media;      
  6.    int ct;
  7.    ct = 0;                      
  8.    soma = 0;
  9.    printf ("Digite [-1] pra sair da repeticao\n");
  10.    printf ("Nota do aluno: ");
  11.    scanf ("%f", & nota);        
  12.    while ( nota != -1 ) {        
  13.       ct ++;                    
  14.       soma += nota;              
  15.       printf ("Nota do aluno: ");
  16.       scanf ("%f", & nota);      
  17.    }      
  18.    if ( ct != 0 ) {              
  19.       media = soma / ct;
  20.           printf ("\n\aQuantidade de alunos: %d", ct);
  21.           printf ("\nMedia da turma: %.1f", media);  
  22.       getch ( );                
  23.       }
  24. }