C-Pointers Question and Answer
C-Pointers Question and Answer
161. Find the output
void main ( )
{
int x=5, *p,q;
p=&x;
q=p;
printf ("%d", ++*q);
}
void main ( )
{
int x=5, *p,q;
p=&x;
q=p;
printf ("%d", ++*q);
}
- 5
- 6
- Compilation error
- None of these
162. Find the output
void main ()
{
char *p=(char*) 0x21;
printf("%d %p", p, p);
}
void main ()
{
char *p=(char*) 0x21;
printf("%d %p", p, p);
}
- 21 0021
- 21 21
- 33 0021
- None of these
163. The following declaration represents
float *p( ) ) ( ) ;
float *p( ) ) ( ) ;
- a function returning float
- a function returning a pointer
- a function returing a pointer to a function returning float.
- a function returning a function returning float
164. Find the output
void main ( )
{ *(char*) 65 = 'a';
printf ("%c", * (char*) 65);
}
void main ( )
{ *(char*) 65 = 'a';
printf ("%c", * (char*) 65);
}
- a
- A
- Error
- None of these
165. Find the output
void main ( )
{
char *p="com\0";
char *q="comd";
if (p==q)
printf ("both are equal");
else
printf ("not equal");
}
void main ( )
{
char *p="com\0";
char *q="comd";
if (p==q)
printf ("both are equal");
else
printf ("not equal");
}
- Both are equal
- Not equal
- Not output
- None of these
166. Find the output.
void main ( )
{
char *p="raja";
char *q="ram";
char s[10];
strcpy (s, p, q);
printf("%s", s);
}
void main ( )
{
char *p="raja";
char *q="ram";
char s[10];
strcpy (s, p, q);
printf("%s", s);
}
- raja
- ram
- rajaram
- Compilation error
167. Find the output.
void main ( )
{
float *f;
printf ("%D %d",
sizeof (f), sizeof (*f));
}
void main ( )
{
float *f;
printf ("%D %d",
sizeof (f), sizeof (*f));
}
- 2 4
- 4 4
- 2 2
- Depends on compiler
168. Find the output
void main ( )
{
char *p={1234};
int *q;
q=p;
while (*p)
{
printf ("%c",, *q);
p++;
q++;
}
}
void main ( )
{
char *p={1234};
int *q;
q=p;
while (*p)
{
printf ("%c",, *q);
p++;
q++;
}
}
- 1234
- 13
- Garbage output
- Compilation error
169. Find the output
void main ( )
{
char *p="hello";
printf ("%. 3s",p);
}
void main ( )
{
char *p="hello";
printf ("%. 3s",p);
}
- hel
- 1lo
- 3helo
- None of these
170. Find the output.
void main ( )
{
int x=5;
void *p;
p=&x;
printf ("d", *(int *)p);
}
void main ( )
{
int x=5;
void *p;
p=&x;
printf ("d", *(int *)p);
}
- 5
- Garbage
- Generic pointer can not be dereferenced
- No output