daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top