Você está na página 1de 12

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.

com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

TITLE: Geometric Sample Programming Placement Paper Level1 (Bolded option is your answer) 1. How will you free the memory allocated by the following program? #include<stdio.h> #include<stdlib.h> #define MAXROW 3 #define MAXCOL 4 int main() { int **p, i, j; p = (int **) malloc(MAXROW * sizeof(int*)); return 0; } A B dealloc(p); C malloc(p, 0); memfree(int p); 2. What will be the output of the program? #include<stdio.h> #include<stdlib.h> int main() { int *p; p = (int *)malloc(20); /* Assume p has address of 1314 */ free(p); printf("%u", p); return 0; }
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

D free(p);

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A 1314

B Garbage value

C 1316

D Random address

3. Assume integer is 2 bytes wide. How many bytes will be allocated for the following code? #include<stdio.h> #include<stdlib.h> #define MAXROW 3 #define MAXCOL 4 int main() { int (*p)[MAXCOL]; p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p)); return 0; } A 56 bytes B 128 bytes C 24 bytes D 12 bytes 4. How many bytes of memory will the following code reserve? #include<stdio.h> #include<stdlib.h> int main() { int *p; p = (int *)malloc(256 * 256); if(p == NULL) printf("Allocation failed"); return 0;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

} A 65536 B Allocation failed C Error D No output

5. Assume integer is 2 bytes wide. What will be the output of the following code? #include<stdio.h> #include<stdlib.h> #define MAXROW 3 #define MAXCOL 4 int main() { int (*p)[MAXCOL]; p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p)); printf("%d, %d\n", sizeof(p), sizeof(*p)); return 0; } A 2, 8 B 4, 16 C 8, 24 D 16, 32 6. What is the output of the program? #include<stdio.h> int main() { extern int a; printf("%d\n", a); return 0; }
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

int a=20; A 20 B0 C Garbage Value D Error

7. What is the output of the program #include<stdio.h> int main() { struct emp { char name[20]; int age; float sal; }; struct emp e = {"Tiger"}; printf("%d, %f\n", e.age, e.sal); return 0; } A 0, B Garbage values 0.000000

C Error

D None of above

8. What will be the output of the program? #include<stdio.h> int X=40; int main() { int X=20; printf("%d\n", X); return 0;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

} A 20 B 40 C Error D No Output

9. What is the output of the program #include<stdio.h> int main() { int x = 10, y = 20, z = 5, i; i = x < y < z; printf("%d\n", i); return 0; } A0 B1

C Error

D None of these

10. When we mention the prototype of a function? A Defining B Declaring C Prototyping D Calling

11. What will you do to treat the constant 3.14 as a long double? A use 3.14LD B use 3.14L C use 3.14DL D use 3.14LF

12. We want to round off x, a float, to an int value, The correct way to do is A y = (int)(x + B y = int(x + 0.5) 0.5) C y = (int)x + 0.5 D y = (int)((int)x + 0.5)

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

13. What will you do to treat the constant 3.14 as a float? A use float(3.14f) B use 3.14f C use f(3.14) D use (f)(3.14)

14. Can you combine the following two statements into one? char *p; p = (char*) malloc(100); A char p = B char *p = (char) *malloc(100); malloc(100);

C char *p = D char *p = (char*)malloc(100 (char ); *)(malloc*)(100 ); 15. How many bytes are occupied by near, far and huge pointers (DOS)? A near=2 B near=4 far=8 far=4 huge=4 huge=8 C near=2 far=4 huge=8 D near=4 far=4 huge=8

16. What would be the equivalent pointer expression for referring the array element a[i][j][k][l] A B C (((a+i)+j)+k+l) ((((a+i)+j)+k)+ *(*(*(*(a+i)+j)+k) l) +l) 17. What will be the output of the program ? #include<stdio.h> int main() { int i=3, *j, k; j = &i;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

D ((a+i)+j+k+l)

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

printf("%d\n", i**j*i+*j); return 0; } A 30 B 27 C9 D3

18. What will be the output of the program ? #include<stdio.h> int main() { char str[20] = "Hello"; char *const p=str; *p='M'; printf("%s\n", str); return 0; } A Mello B Hello

C HMello

D MHello

19. What will be the output of the program ? #include<stdio.h> int main() { printf("%c\n", 7["IndiaBIX"]); return 0; } A Error: in B Nothing will printf print

C print "X" of IndiaBIX

D print "7"

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

20. If the size of integer is 4bytes, What will be the output of the program? #include<stdio.h> int main() { int arr[] = {12, 13, 14, 15, 16}; printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0])); return 0; } A 10, 2, 4 B 20, 4, 4 C 16, 2, 2 D 20, 2, 2 21. In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets(). What will str contain? A "I am a boy\r\n\0" B "I am a boy\r\0" C "I am a boy\n\0" D "I am a boy"

22. Which of the following operations can be performed on the file "NOTES.TXT" using the below code? FILE *fp; fp = fopen("NOTES.TXT", "r+"); A Reading B Writing

C Appending

D Read and Write

23. To scan a and b given below, which of the following scanf() statement will you use? #include<stdio.h> float a;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

double b; A scanf("%f B scanf("%Lf %Lf", C scanf("%f %Lf", %f", &a, &b); &a, &b); &a, &b); 24. In the following code what is 'P'? typedef char *charp; const charp P; A P is a B P is a character constant constant D scanf("%f %lf", &a, &b);

C P is character type

D None of above

25. In the following code, the P2 is Integer Pointer or Integer? typedef int *ptr; ptr p1, p2; A Integer B Integer pointer

C Error in declaration

D None of above

26. Which of the following correctly shows the hierarchy of arithmetic operations in C? A/+*B*-/+ C+-/* D/*+-

27. Which of the following is the correct order of evaluation for the below expression? z=x+y*z/4%2-1 A*/%+-= B=*/%+C/*%-+= D*%/-+= 28. In which stage the following code #include<stdio.h> gets replaced by the contents of the file stdio.h
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A During editing

B During linking

C During execution

D During preprocessing

29. How will you print \n on the screen? A printf("\n"); B echo "\\n"; C printf('\n'); D printf("\\n");

30. Declare the following statement? "An array of three pointers to chars". A char *ptr[3](); B char *ptr[3]; C char (*ptr[3])(); D char **ptr[3];

31. Declare the following statement? "A pointer to a function which receives an int pointer and returns float pointer". A float B float *(*ptr)(int) C float D float *(ptr)*int; *(*ptr)(int*) (*ptr)(int) 32. What do the following declaration signify? void (*cmp)(); A cmp is a B cmp is a void C cmp is a D cmp is a pointer to an type pointer function that pointer to a void function function. return a void function which type. pointer. returns void . 33. Declare the following statement? "A pointer to a function which receives nothing and returns nothing". A void *(ptr)*int; B void *(*ptr)() C void *(*ptr)(*) D void (*ptr)()

34. What do the following declaration signify? char *scr;


Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A scr is a B scr is a function C scr is a pointer pointer to pointer. to char. pointer variable. 35. What will be the output of the program in Turbo C? #include<stdio.h>

D scr is a member of function pointer.

int main() { char near *near *ptr1; char near *far *ptr2; char near *huge *ptr3; printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3)); return 0; } A 4, 4, 8 B 4, 4, 4 C 2, 4, 8 D 2, 4, 4 36. Point out the error in the following program. #include<stdio.h> void display(int (*ff)()); int main() { int show(); int (*f)(); f = show; display(f); return 0;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

} void display(int (*ff)()) { (*ff)(); } int show() { printf("IndiaBIX"); } A Error: B Error: invalid invalid function call parameter in f=show; function display()

C No error and prints "IndiaBIX"

D No error and prints nothing.

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Você também pode gostar