alansam

Format array of floating points

Jun 1st, 2022 (edited)
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     double a[] = {
  5.         10.67, 68.43, 56.55, 92.60, 90.65,
  6.     };
  7.     size_t const a_sz = sizeof(a) / sizeof(*a);
  8.  
  9.     printf("array elements are:\n");
  10.  
  11.     for (size_t i = 0; i < a_sz; i++) {
  12.         printf("%8.2f", a[i]);
  13.     }
  14.     putchar('\n');
  15.  
  16.     return 0;
  17. }
  18.  
Add Comment
Please, Sign In to add comment