CS 2213/1, Spring 2005 Quiz 1 Questions |
Last Name: | First Name: |
Don't spend too much time on any one question.
/* start of a comment, but here is /* a comment */ nested within the outer comment */
#include <stdio.h> int main() { int a[5] = {0, 0, 0, 0, 0}; int i; for (i = -10000; i < 10; i++) if (a[i] == 0 && i >= 0) a[i] = i + 10; } | #include <stdio.h> int main() { int a[5] = {0, 0, 0, 0, 0}; int i; for (i = -10000; i < 10; i++) if (i >= 0 && a[i] == 0) a[i] = i + 10; } |
One of these two has a very serious flaw (although both will compile, one may not run correctly).
#include <stdio.h> int main() { int a = -1; int b = ( a > 0 ? 47 : 53 ); printf("b: %i\n", b); } |
#include <stdio.h> #define PI 3.14159265358979 int main() { printf("The value of \"PI\" is: %7.4f\n", PI); } |