0% found this document useful (0 votes)
79 views3 pages

Find The Output of The Following Snippet. #Include

This document contains 10 coding questions and their outputs. The questions cover topics like pointers, arrays, structures, typecasting and more. For example, question 1 asks about the difference between a character pointer and character array. Question 2 is about sizes of different pointer types in DOS. Question 3 prints the next character from a string array.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views3 pages

Find The Output of The Following Snippet. #Include

This document contains 10 coding questions and their outputs. The questions cover topics like pointers, arrays, structures, typecasting and more. For example, question 1 asks about the difference between a character pointer and character array. Question 2 is about sizes of different pointer types in DOS. Question 3 prints the next character from a string array.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

The following declarations are NOT the same:


char *p;
char a[20];
What is the difference?
2.

How many bytes are occupied by near, far and huge pointers (DOS)?
A.

near=2 far=4 huge=4

B.

near=4 far=8 huge=8

C.

near=2 far=4 huge=8

D.

near=4 far=4 huge=8

3. Find the output of the following snippet.


#include<stdio.h>
int main()
{
static char *s[] = {"black", "white", "pink", "violet"};
char **ptr[] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
++p;
printf("%s", **p+1);
return 0;
}

2.

What will be the output of the program ?

#include<stdio.h>
int main()
{
int i=3, *j, k;
j = &i;
printf("%d\n", i**j*i+*j);
return 0;
}
3.

What will be the output of the program ?

#include<stdio.h>
int main()
{
int x=30, *y, *z;
y=&x; /* Assume address of x is 500 and integer is 4 byte size */
z=y;
*y++=*z++;
x++;
printf("x=%d, y=%d, z=%d\n", x, y, z);
return 0;
}

4. What will be the output of the program ?


#include<stdio.h>
void fun(void *p);
int i;
int main()
{
void *vptr;
vptr = &i;
fun(vptr);
return 0;
}
void fun(void *p)
{
int **q;
q = (int**)&p;
printf("%d\n", **q);
}
5. What will be the output of the program ?
#include<stdio.h>
int main()
{
char *str;
str = "%s";
printf(str, "K\n");
return 0;
}
8.

What will be the output of the program?

#include<stdio.h>
int *check(static int, static int);
int main()
{
int *c;
c = check(10, 20);
printf("%d\n", c);
return 0;
}
int *check(static int i, static int j)
{
int *p, *q;
p = &i;
q = &j;
if(i >= 45)
return (p);
else
return (q);
}
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;
}
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;
}

You might also like