adventuretimeh

valore assoluto

Oct 17th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. int main(int argc, char *argv[]) {
  7.     float a;
  8.     float val;
  9.     printf("dammi un numero");
  10.     scanf("%f",&a);
  11.     val = a * -1;
  12.     if (a>=0)
  13.     {
  14.         printf("il valore assoluto di %6.2f e' %6.2f,",a,a);
  15.     }
  16.     else
  17.     printf("il valore assoluto di %6.2f e' %6.2f,",a,val);
  18.    
  19.     return 0;
  20. }
Add Comment
Please, Sign In to add comment