What happens if you try to compile and run this program?
#include
int main(int argc, char *argv[]) {
int i = 10 - 2 / 5 * 10 / 2 - 1;
printf("%d",i);
return 0;
}
Choose the right answer:
What happens if you try to compile and run this program?
#include
#include
struct STR {
int i;
char c[20];
float f;
};
int main (int argc, char *argv[]) {
struct STR str = { 1, "Hello", 3 };
printf("%d", str.i + strlen(str.c));
return 0;
}
Choose the right answer:
Assume that we can open a file called "file1".
What happens when you try to compile and run the following program?
#include
int main (void) {
FILE *f;
int i;
f = fopen("file1","wb");
fputs("545454",f);
fclose (f);
f = fopen("file1","rt");
fscanf(f,"%d ", &i);
fclose (f) ;
printf("%d",i);
return 0;
}
Choose the right answer:
Assume that ints are 32-bit wide.
What happens if you try to compile and run this program?
#include
typedef union {
int i;
int j;
int k;
} uni;
int main (int argc, char *argv[]) {
uni s;
s.i = 3;
s.j = 2;
s.k = 1;
printf("%d",s.k * (s.i - s.j));
return 0;
}
Choose the right answer:
What happens if you try to compile and run this program?
#define ALPHA 0
#define BETA ALPHA-1
#define GAMMA 1
#define dELTA ALPHA-BETA-GAMMA
#include
int main(int argc, char *argv[]) {
printf ("%d", DELTA);
return 0;
Choose the right answer:
What happens if you try to compile and run this program?
#include
int main (int argc, char *argv[]) {
int i = 1;
for(;i > 128;i *= 2);
printf("%d", i) ;
return 0;
}
-
Choose the right answer:
What happens if you try to compile and run this program?
#include
int i = 0;
int main (int argc, char *argv[]) {
for(i; 1; i++);
printf("%d", i);
return 0;
}
Choose the right answer:
What happens if you try to compile and run this program?
#include
int main (int argc, char *argv[]) {
char *t = "abcdefgh";
char *p = t + 2;
int i;
p++;
p++;
printf("%d ", p[2] - p[-1]);
return 0;
}
Choose the right answer:
What happens if you try to compile and run this program?
#include
int main (int argc, char *argv[]) {
int i = 7 || 0 ;
printf("%d", !! i);
return 0;
}
Choose the right answer:
-
What happens if you try to compile and run this program?
#include
int *f();
int main (int argc, char *argv[]) {
int *p;
p = f();
printf("%d",*p);
return 0;
}
int *f() {
static v = 1;
return &v;
}
Choose the right answer:
Assume that ints are 32-bit wide.
What happens if you try to compile and run this program?
#include
typedef struct
int i;
int j;
int k;
} str;
int main (int argc, char *argv[]) {
str s = { 7, 7, 7 };
printf ("%d", sizeof (s.s));
return 0;
}
Choose the right answer:
What happens when you compile and run the following program?
#include
#define SYM
#define BOL 100
#undef SYM
int main (void) {
#ifdef SYM
int i = 100;
#else
int i= 200;
#endif
int j = i + 200;
printf("%d",i+j);
return 0;
}
Select the correct answer: