Error cannot use static for function parameters 9

Info icon This preview shows pages 15–20. Sign up to view the full content.

View Full Document Right Arrow Icon
Error: cannot use static for function parameters. 9 . What will be the output of the program if the size of pointer is 4-bytes? #include<stdio.h> int main() { printf("%d, %d\n", sizeof(NULL), sizeof("")); return 0; } Ans. 4, 1 Explanation: In TurboC, the output will be 2, 1 because the size of the pointer is 2 bytes in 16-bit platform. But in Linux, the output will be 4, 1 because the size of the pointer is 4 bytes. This difference is due to the platform dependency of C compiler.
Image of page 15

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
16 10. What will be the output of the program ? #include<stdio.h> int main() { void *vp; char ch=74, *cp="JACK"; int j=65; vp=&ch; printf("%c", *(char*)vp); vp=&j; printf("%c", *(int*)vp); vp=cp; printf("%s", (char*)vp+2); return 0; } Ans. JACK 11 . What will be the output of the program? #include<stdio.h> int main() { int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8}; int *p, *q; p = &arr[1][1][1]; q = (int*) arr; printf("%d, %d\n", *p, *q); return 0; } Ans. 8, 10 12 . What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes? #include<stdio.h> int main() {
Image of page 16
17 int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1)); return 0; } Ans. 1006, 2, 2 13. What will be the output of the program? #include<stdio.h> int main() { int arr[3] = {2, 3, 4}; char *p; p = arr; p = (char*)((int*)(p)); printf("%d, ", *p); p = (int*)(p+1); printf("%d", *p); return 0; } Ans. 2, 0 14 . What will be the output of the program? #include<stdio.h> int main() { char *str; str = "%d\n"; str++; str++; printf(str-2, 300); return 0; } Ans. 300
Image of page 17

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
18 15 . What will be the output of the program? #include<stdio.h> int main() { printf("%c\n", 7["IndiaAMU"]); return 0; } Ans. print "U" of IndiaAMU. 16. What will be the output of the program? #include<stdio.h> int main() { char str[] = "peace"; char *s = str; printf("%s\n", s++ +3); return 0; } Ans. ce 17. What will be the output of the program? #include<stdio.h> int main() { char *p; p="hello"; printf("%s\n", *&*&p); return 0; } Ans.
Image of page 18
19 hello 18 . What will be the output of the program assuming that the array begins at location 1002? #include<stdio.h> int main() { int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2}, {2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} }; printf("%u, %u, %u, %d\n", a, *a, **a, ***a); return 0; } Ans. 1002, 1002, 1002, 1 19 . What will be the output of the program? #include<stdio.h> power(int**); int main() { int a=5, *aa; /* Address of 'a' is 1000 */ aa = &a; a = power(&aa); printf("%d\n", a); return 0; } power(int **ptr) { int b; b = **ptr***ptr; return (b); } Ans.
Image of page 19

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 20
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern