ssoni

casting.c

Dec 7th, 2021 (edited)
833
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3.  
  4. int main(void)
  5. {
  6.     int a;
  7.     a=19/6;
  8.     printf("a=%i\n", a);
  9.  
  10.     float b;
  11.     b=19/6;
  12.     printf("b=%f\n", b);
  13.  
  14.     float c;
  15.     c=(float)19/(float)6;
  16.     printf("c=%f\n", c);
  17.  
  18.     float d;
  19.     d=(float)19/6;
  20.     printf("d=%.1f\n", d);
  21.  
  22.     float e;
  23.     float f;
  24.     float g;
  25.     e = 10.2 * (1/2);
  26.     e = 10.2 * ((float)1 / 2);
  27.     f = 10.2 * 1.0 / 2;
  28.     g = (10.2 * 1) / 2;
  29.     printf("e=%f\n", e);
  30.     printf("f=%f\n", f);
  31.     printf("g=%f\n", g);
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
Add Comment
Please, Sign In to add comment