Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. float nota1, nota2, calc ;
  7. char op;
  8.  
  9. printf("Digite a opção A ou P : ");
  10. scanf("%c", &op);
  11. printf("Digite as notas: \n");
  12. scanf("%f %f", &nota1, &nota2 );
  13.  
  14. calc = media (nota1, nota2, op);
  15.  
  16. printf("Media= %f", calc);
  17.  
  18. return 0;
  19. }
  20.  
  21. float media(float n1, float n2, char op) {
  22. if (op == 'A') {
  23. return (n1 + n2 ) / 2;
  24. } else if (op == 'P') {
  25. return ( n1*2 + n2*3) / 5;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement