Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Suppose you have the following Program.
- //No includes
- int main()
- {
- printf("Hello World!!!\n");
- //No returns
- }
- Will this code compile and run successfully?
- ===============================================================
- 2. Let us suppose a program executes the following instructions:
- for (i = 0; i < n; i++) fork();
- How many processes are created in total (in terms of n)?
- ===============================================================
- 3. Say we run this program.
- if (fork() == 0)
- { a = a + 5; printf(“x = %d,y = %d\n”, a, &a); }
- else { a = a –5; printf(“u = %d, v = %d\n”, a, &a); }
- ===============================================================
- Which of the following are true ?
- (a) u = x + 10 and v = y
- (b) u = x + 10 and v != y
- (c) u + 10 = x and v = y
- (d) u + 10 = x and v != y
- ===============================================================
- 4. What is the output of this program ?
- int main () {
- int i, j, *p, *q;
- p = &i;
- q = &j;
- *p = 5;
- *q = *p + i;
- printf("i = %d, j = %d\n", i, j);
- return 0;
- }
- a) i = 5, j = 10
- b) i = 5, j = 5
- c) i = 10, j = 5
- d) i = 10, j = 10
- e) Nothing. The program will most likely crash.
- ================================================================
- 5. Where does the "hello world" reside ?
- int main() {
- const char *str = "hello world";
- printf("%s\n", str);
- }
- a) .text section b) .data section c) .bss section d) stack e) heap
- ================================================================
- 6. What does the following command give you on a 64 bit machine with a 32 bit compiler?
- {
- printf("char=%d, int=%d, long=%d", sizeof(char), sizeof(int), sizeof(long));
- }
- a) char=4, int=4, long=4
- b) char=1, int=4, long=4
- c) char=1, int=4, long=8
- d) char=1, int=8, long=8
- e) compilation error
- 7. Suppose you compile a code and send the binary to your friends computer (Both your computers have different configuration etc).
- Will it run ? When will it not run?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement