Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. 3. Describe what this simple C99 program does and under what circumstances it will return true or false. Explain why it may sometimes be false.
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. float f[argc - 1];
  9. for (int i = 1; i < argc; i++)
  10. f[i - 1] = atof(argv[i]); // string to float
  11.  
  12. float r1 = 0;
  13. for (int i = 0; i < argc - 1; i++)
  14. r1 += f[i];
  15.  
  16. float r2 = 0;
  17. for (int i = argc - 2; i >= 0; i--)
  18. r2 += f[i];
  19.  
  20. return r1 != r2;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement