C Language - Pointers

You Are Here :: Home > C Language > Pointers - General Questions

 
25.

What will be output of following c program?

#include
int main(){
float *p=(float *)1000;
float *q=(float *)2000;
printf("Difference=%d",q-p);
return 0;
}

A. Difference= 200 B. Difference= 250
C. Difference= 500 D. Difference= 1000




26.

main()

{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
}

A. 2 2 8 3 4 4 6 7 5 B. 2 2 2 2 2 3 4 6 5
C. 2 3 4 6 5 8 8 8 8 D. 2 2 2 2 2 2 3 5 7




27.

main()

{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}

A. 0 0 1 1 1 B. 0 0 1 2 1
C. 0 0 1 3 1 D. 0 0 2 2 2




28.

What will be output if you will execute following code?

#include
int * function();
int main(){
auto int *x;
int *(*ptr)();
ptr=&function;
x=(*ptr)();
printf("%d",*x);
return 0;
}
int *function(){
static int a=10;
return &a;
}

A. 2 B. 4
C. 10 D. a




29.

main()

{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}

A. 1 1 B. 1 2
C. 1 4 D. 2 2




30.

What will be output if you will execute following code?

#include
char * call(int *,float *);
int main(){
char *string;
int a=2;
float b=2.0l;
char *(*ptr)(int*,float *);
ptr=&call;
string=(*ptr)(&a,&b);
printf("%s",string);
return 0;
}
char *call(int *i,float *j){
static char *str="careersadda.com";
str=str+*i+(int)(*j);
return str;
}

A. careersadda.com B. eersadda.com
C. carsadda.com D. ersadda.com




« previous

1

2

3

4

5

6

7

8

9

...

next »

 
 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on