Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. main () {
  5.  
  6. char c1;
  7. float valor = 0.0f;
  8. float factor = 0.0f;
  9. int i = 1;
  10.  
  11. printf ("Escreva um digito: ");
  12. while (i<=5) {
  13. scanf (" %c", &c1);
  14. int teste = c1 - '0';
  15. if ((c1>='0') && (c1<='9')){
  16. factor = teste*(1000/pow (10,i));
  17. printf("%f\n",factor);
  18. valor=valor+factor;
  19. i=i+1;
  20. }
  21. else if(c1 == ',')
  22. i=i;
  23. else
  24. exit (1);
  25. }
  26.  
  27. printf ("Boa! Muito obrigado\n\n");
  28. printf ("O número é %.2f\n", valor);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement