Académique Documents
Professionnel Documents
Culture Documents
C pointers questions
Share
More
Next Blog
Create Blog
Sign In
C Programming Questions
C Interview Questions
C Programs
C Test
C programming pdf
Program of c++
Create projects
Sql Server
Search
C Programming Language
C++ Language
C++ Code
C QUESTIONS AND ANSWERS
C program examples
C interview questions and answers
Data type questions
Variable naming rule questions
Operators questions
Control flow questions
Switch case questions
Looping questions
www.cquestions.com/2012/02/c-pointers-questions.html
31/07/2013
Pointer questions
String questions
Printf,Scanf questions
C pointers questions
Jobs.
C pointers questions
Preprocessor questions
Structure questions
Commad line argument
C questions in Linux
C online test
C mixed practice sets
C tricky questions
Example of recursion in c
1.
C programming forums
C TUTORIAL
#include<stdio.h>
int main(){
int a = 320;
char *ptr;
ptr =( char *)&a;
printf("%d ",*ptr);
return 0;
}
(A) 2
Pointers tutorial in c
(B) 320
Function tutorial in c
(C) 64
Array tutorial in c
Preprocessor tutorial in c
Advanced c tutorial
POPULAR POSTS
Output
E x p l a n a t i o n :
C program examples
Check given number is prime
number or not using c program
C interview questions and answers
2/30
31/07/2013
C pointers questions
Turbo C ++4.5: 64
Linux GCC: 64
Visual C++: 64
As we know int is two byte data byte while char is one byte data byte.
char pointer can keep the address one byte at time.
Binary value of 320 is 00000001 01000000 (In 16 bit)
Delivered by FeedBurner
So ptr is pointing only first 8 bit which color is green and Decimal
value is 64.
STANDARD OF QUESTIONS ?
Excellent
2.
Good
Avg
Worst
Vote
Show results
www.cquestions.com/2012/02/c-pointers-questions.html
#include<stdio.h>
#include<conio.h>
int main(){
void (*p)();
int (*q)();
int (*r)();
p = clrscr;
3/30
31/07/2013
C pointers questions
SUBSCRIBE TO
Posts
Comments
MY HEADLINES
q = getch;
r = puts;
(*p)();
(*r)("cquestionbank.blogspot.com");
(*q)();
return 0;
(A) NULL
(B) cquestionbank.blogspot.com
(C) c
C basic questions
Program in c language
Simple program example in c
language
Tricky c questions and answers
Output
E x p l a n a t i o n :
3.
What will be output of following program?
#include<stdio.h>
int main(){
www.cquestions.com/2012/02/c-pointers-questions.html
4/30
31/07/2013
C pointers questions
ABOUT ME
ritesh kumar
Follow
1.2k
View my complete
profile
GOOGLE+ BADGE
int i = 3;
int *j;
int **k;
j=&i;
k=&j;
printf("%u %u %d ",k,*k,**k);
return 0;
(B) Address, 3, 3
(C) 3, 3, 3
(D) Compilation error
(E) None of above
Output
Explanation:
Memory representation
www.cquestions.com/2012/02/c-pointers-questions.html
5/30
31/07/2013
C pointers questions
4.
www.cquestions.com/2012/02/c-pointers-questions.html
6/30
31/07/2013
C pointers questions
(A) 80
(B) 81
(C) 82
(D) Compilation error
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: 81
Turbo C ++4.5: Compilation error
Linux GCC: Compilation error
Visual C++: Compilation error
www.cquestions.com/2012/02/c-pointers-questions.html
7/30
31/07/2013
C pointers questions
5.
What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
char *ptr1 = NULL;
char *ptr2 = 0;
strcpy(ptr1," c");
strcpy(ptr2,"questions");
printf("\n%s %s",ptr1,ptr2);
return 0;
}
(A) c questions
(B) c (null)
(C) (null) (null)
(D) Compilation error
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: (null) (null)
Turbo C ++4.5: Run time error
www.cquestions.com/2012/02/c-pointers-questions.html
8/30
31/07/2013
C pointers questions
6.
What will be output of following program?
#include<stdio.h>
int main(){
int huge *a =(int huge *)0x59990005;
int huge *b =(int huge *)0x59980015;
if(a == b)
printf("power of pointer");
else
printf("power of c");
return 0;
}
E x p l a n a t i o n :
Turbo C++ 3.0: power of pointer
Turbo C ++4.5: power of c
www.cquestions.com/2012/02/c-pointers-questions.html
9/30
31/07/2013
C pointers questions
7.
What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
register a = 25;
int far *p;
p=&a;
printf("%d ",*p);
return 0;
}
(A) 25
(B) 4
(C) Address
(D) Compilation error
(E) None of above
Output
www.cquestions.com/2012/02/c-pointers-questions.html
10/30
31/07/2013
C pointers questions
E x p l a n a t i o n :
Turbo C++ 3.0: Compilation error
Turbo C ++4.5: Compilation error
Linux GCC: Compilation error
Visual C++: Compilation error
Register data type stores in CPU. So it has not any memory address.
Hence we cannot write &a.
8.
What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
char far *p,*q;
printf("%d %d",sizeof(p),sizeof(q));
return 0;
}
(A) 2 2
(B) 4 4
(C) 4 2
(D) 2 4
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: 4 4
www.cquestions.com/2012/02/c-pointers-questions.html
11/30
31/07/2013
C pointers questions
Turbo C ++4.5: 4 4
Linux GCC: Compilation error
Visual C++: Compilation error
9.
What will be output of following program?
#include<stdio.h>
int main(){
int a = 10;
void *p = &a;
int *ptr = p;
printf("%u",*ptr);
return 0;
}
(A) 10
(B) Address
(C) 2
(D) Compilation error
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: 10
www.cquestions.com/2012/02/c-pointers-questions.html
12/30
31/07/2013
C pointers questions
Turbo C ++4.5: 10
Linux GCC: 10
Visual C++: 10
Void pointer can hold address of any data type without type casting.
Any pointer can hold void pointer without type casting.
10.
What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
int register a;
scanf("%d",&a);
printf("%d",a);
return 0;
}
//if a=25
(A) 25
(B) Address
(C) 0
(D) Compilation error
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: Compilation error
www.cquestions.com/2012/02/c-pointers-questions.html
13/30
31/07/2013
C pointers questions
Register data type stores in CPU. So it has not any memory address.
Hence we cannot write &a.
11.
What will be output of following program?
#include<stdio.h>
int main(){
char arr[10];
arr = "world";
printf("%s",arr);
return 0;
}
(A) world
(B) w
(C) Null
(D) Compilation error
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: Compilation error
Turbo C ++4.5: Compilation error
www.cquestions.com/2012/02/c-pointers-questions.html
14/30
31/07/2013
C pointers questions
12.
What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
int a,b,c,d;
char *p = ( char *)0;
int *q = ( int *q)0;
float *r = ( float *)0;
double *s = 0;
a = (int)(p+1);
b = (int)(q+1);
c = (int)(r+1);
d = (int)(s+1);
printf("%d %d %d %d",a,b,c,d);
return 0;
}
(A) 2 2 2 2
(B) 1 2 4 8
(C) 1 2 2 4
(D) Compilation error
(E) None of above
Output
www.cquestions.com/2012/02/c-pointers-questions.html
15/30
31/07/2013
C pointers questions
E x p l a n a t i o n :
13.
What will be output of following program?
#include<stdio.h>
#include<string.h>
int main(){
int a = 5,b = 10,c;
int *p = &a,*q = &b;
c = p - q;
printf("%d" , c);
return 0;
}
(A) 1
(B) 5
(C) -5
www.cquestions.com/2012/02/c-pointers-questions.html
16/30
31/07/2013
C pointers questions
E x p l a n a t i o n :
Turbo C++ 3.0: 1
Turbo C ++4.5: 1
Linux GCC: 1
Visual C++: 2
14.
What will be output of following program?
#include<stdio.h>
unsigned long int (* avg())[3]{
static unsigned long int arr[3] = {1,2,3};
return &arr;
}
int main(){
unsigned long int (*ptr)[3];
ptr = avg();
printf("%d" , *(*ptr+2));
return 0;
}
(A) 1
(B) 2
(C) 3
(D) Compilation error
www.cquestions.com/2012/02/c-pointers-questions.html
17/30
31/07/2013
C pointers questions
E x p l a n a t i o n :
Turbo C++ 3.0: 3
Turbo C ++4.5: 3
Linux GCC: 3
Visual C++: 3
15.
What will be output of following program?
#include<stdio.h>
int main(){
int * p , b;
b = sizeof(p);
printf("%d" , b);
return 0;
}
(A) 2
(B) 4
(C) 8
(D) Compilation error
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: 2 or 4
Turbo C ++4.5: 2 or 4
www.cquestions.com/2012/02/c-pointers-questions.html
18/30
31/07/2013
C pointers questions
Linux GCC: 4
Visual C++: 4
16.
What will be output of following program?
#include<stdio.h>
int main(){
int i = 5 , j;
int *p , *q;
p = &i;
q = &j;
j = 5;
printf("%d %d",*p,*q);
return 0;
}
(A) 5 5
(B) Address Address
(C) 5 Address
(D) Compilation error
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: 5 5
Turbo C ++4.5: 5 5
www.cquestions.com/2012/02/c-pointers-questions.html
19/30
31/07/2013
C pointers questions
Linux GCC: 5 5
Visual C++: 5 5
17.
What will be output of following program?
#include<stdio.h>
int main(){
int i = 5;
int *p;
p = &i;
printf(" %u %u", *&p , &*p);
return 0;
}
(A) 5 Address
(B) Address Address
(C) Address 5
(D) Compilation error
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: Address Address
Turbo C ++4.5: Address Address
Linux GCC: Address Address
Visual C++: Address Address
20/30
31/07/2013
C pointers questions
i.e. *&a = a
so *&p = p which store address of integer i
&*p = &*(&i) //since p = &i
= &(*&i)
= &i
So second output is also address of i
18.
What will be output of following program?
#include<stdio.h>
int main(){
int i = 100;
printf("value of i : %d addresss of i : %u",i,&i);
i++;
printf("\nvalue of i : %d addresss of i : %u",i,&i);
return 0;
}
(A)
value of i : 100 addresss of i : Address
value of i : 101 addresss of i : Address
(B)
value of i : 100 addresss of i : Address
value of i : 100 addresss of i : Address
(C)
value of i : 101 addresss of i : Address
value of i : 101 addresss of i : Address
21/30
31/07/2013
C pointers questions
Output
E x p l a n a t i o n :
Turbo C++ 3.0:
value of i : 100 addresss of i : Address
value of i : 101 addresss of i : Address
Turbo C ++4.5:
value of i : 100 addresss of i : Address
value of i : 101 addresss of i : Address
Linux GCC:
value of i : 100 addresss of i : Address
value of i : 101 addresss of i : Address
Visual C++:
value of i : 100 addresss of i : Address
value of i : 101 addresss of i : Address
Within the scope of any variable, value of variable may change but its
address will never change in any modification of variable.
19.
www.cquestions.com/2012/02/c-pointers-questions.html
22/30
31/07/2013
C pointers questions
(A) 25
(B) Address
(C) Garbage
(D) Compilation error
(E)None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: 26
Turbo C ++4.5: Compilation error
Linux GCC: Compilation error
Visual C++: Compilation error
23/30
31/07/2013
C pointers questions
20.
What will be output of following program?
#include<stdio.h>
int main(){
int i = 3;
int *j;
int **k;
j = &i;
k = &j;
printf("%u %u %u",i,j,k);
return 0;
}
(A) 3 Address 3
(B) 3 Address Address
(C) 3 3 3
(D) Compilation error
(E) None of above
Output
E x p l a n a t i o n :
Turbo C++ 3.0: 3 Address Address
www.cquestions.com/2012/02/c-pointers-questions.html
24/30
31/07/2013
C pointers questions
Pointer Tutorial
More pointer questions
Array questions
String questions
Function questions
+5 Recommend this on Google
12 comments:
www.cquestions.com/2012/02/c-pointers-questions.html
25/30
31/07/2013
C pointers questions
26/30
31/07/2013
C pointers questions
int main(){
unsigned long int (*ptr)[3];
ptr = avg();
printf("%d" , *(*ptr+2));
return 0;
}
Reply
www.cquestions.com/2012/02/c-pointers-questions.html
27/30
31/07/2013
C pointers questions
www.cquestions.com/2012/02/c-pointers-questions.html
28/30
31/07/2013
C pointers questions
Enter your comment...
Preview
Home
Older Post
Questions Answers
C++ Language
C Programming PDF
SHARE IT
Share this on Facebook
Tweet this
View stats
(NEW) Appointment gadget >>
MUST VISIT
C LOVER COMMUNITY
www.cquestions.com/2012/02/c-pointers-questions.html
29/30
31/07/2013
C pointers questions
Join this site
w ith Google Friend Connect
www.cquestions.com/2012/02/c-pointers-questions.html
30/30