Advertisement
bobbinz

Various C Constructs

Oct 15th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void)
  5. {
  6.     int answer;
  7.     short x = 1;
  8.     long y = 2;
  9.     float u = 3.0;
  10.     double v = 4.4;
  11.     long double w = 5.54;
  12.     char c = 'p';;
  13.  
  14.     printf("Date : %s\n", __DATE__);
  15.     printf("Time : %s\n", __TIME__);
  16.     printf("File : %s\n", __FILE__);
  17.     printf("Line : %d\n", __LINE__);
  18.     printf("\nEnter 1 or 0 : ");
  19.     scanf("%d", &answer);
  20.  
  21.     printf("%s\n", answer?"\nYou said YES\n":"\nYou said NO\n");
  22.  
  23.     printf("The size of int %d\n", sizeof(answer));
  24.     printf("The size of short %d\n", sizeof(x));
  25.     printf("The size of long %d\n", sizeof(y));
  26.     printf("The size of float %d\n", sizeof(u));
  27.     printf("The size of double %d\n", sizeof(v));
  28.     printf("The size of long double %d\n", sizeof(w));
  29.     printf("The size of char %d\n", sizeof(c));
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement