Pointer C Apps
Pointer C Apps
Pointer C Apps
#include<stdio.h>
int main(){
int a = 130;
char *ptr;
printf("%d ",*ptr);
return 0;
A. -126
C. Garbage value
#include<stdio.h>
int main(){
int i = 3;
int *j;
int **k;
j = &i;
k = &j;
k++;
printf("%d ",**k);
return 0;
}
A. Garbage value
B. Compilation Error
C. Run time error
D. Linker Error
#include<stdio.h>
int main(){
int i = 3;
int *j;
j = &i;
j++;
printf("%d ",*j);
return 0;
}
A. Linker Error
B. Run time error
C. Compilation Error
D. Garbage value
#include<stdio.h>
#include<string.h>
int main(){
char *ptr = "hello";
char a[22];
strcpy(a, "world");
printf("\n%s %s",ptr, a);
return 0;
}
A. hello world
B. Run time error
C. Compilation Error
D. Garbage value
#include<stdio.h>
#include<string.h>
int main(){
char *ptr = "hello";
char a[22];
*ptr = "world";
printf("\n%s %s",ptr, a);
return 0;
}
A. Linker Error
B. Run time error
C. Compilation Error
D. Garbage value
#include<stdio.h>
int main()
{
char *ptr = "helloworld";
printf(ptr + 4);
return 0;
}
A. oworld
B. world
C. hell
D. hello
#include<stdio.h>
int main()
{
char *ptr = "2braces";
printf("%c\n",*&*ptr);
return 0;
}
A. Address of 2
B. Compilation Error
C. 2
D. Run time error
#include<stdio.h>
#include<string.h>
int main(){
register a = 1;
int far *ptr;
ptr = &a;
printf("%u",ptr);
return 0;
}
A. Address of a
B. Run time error
C. Garbage value
D. Compile time error
#include<stdio.h>
#include<string.h>
int main(){
char a = 30, b = 5;
char *p = &a, *q = &b;
printf("%d", p - q);
return 0;
}
A. 1
B. Run time error
C. Compilation Error
D. 25
#include<stdio.h>
int main(){
int *ptr, b;
b = sizeof(ptr);
printf("%d" , b);
return 0;
}
A. 2
B. 4
C. Compilation Error
D. Run time error