Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /* Zadatak 02
  2. * Izračunati površinu trougla upotrebom
  3. * Heronovog obrasca, vrednosti stranica uneti sa
  4. * tastature. Na izlazu štampati vrednost površine
  5. * trougla na dve decimale.
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <math.h>
  10.  
  11. int main() {
  12. double a, b, c; //stranice
  13. double s; //poluobim
  14. double P; //površina
  15.  
  16. printf("Unesite stranice trougla:\n");
  17. //Učitavanje prve stranice trougla
  18. printf("a=");
  19. scanf("%lf",&a);
  20. //Učitavanje druge stranice trougla
  21. printf("b=");
  22. scanf("%lf",&b);
  23. //Učitavanje treće stranice trougla
  24. printf("c=");
  25. scanf("%lf",&c);
  26. //Računanje poluobima
  27. s = (a + b + c) / 2;
  28. //Računanje i ispis površine na dve decimale
  29. P = sqrt(s * (s - a) * (s - b) * (s - c));
  30. printf("P=%.2lf\n", P);
  31. //Uspešan završetak programa
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement