c interview questions on pointers
This article covers all the pointers based c interview questions for a fresher on various patter for fresser interview in MNC’s
- Between the int pointer and long double pointer which pointer will consume more memory space?
- What is the size of a void pointer in c?
What will be the output of following c program?
#include <stdio.h> int main() { int * ptr = (int*) 1000; ptr = ptr + 1; printf(" %u", ptr); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int * p1; float * p2; double * p3; char * p4; printf("\n%u", sizeof(p1)); printf("\n%u", sizeof(p2)); printf("\n%u", sizeof(p3)); printf("\n%u", sizeof(p4)); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int far* p1; float far* p2; double far* p3; char far* p4; printf("\n%u", sizeof(p1)); printf("\n%u", sizeof(p2)); printf("\n%u", sizeof(p3)); printf("\n%u", sizeof(p4)); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int* p; int a = 5; *p++; printf("%d", a); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int* p; int a = 5; ++ * p; printf("%d", a); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { char* p; int a = -1; p = (char*)&a; *p = 0; printf("%d", a); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int* p; p = (int*) 100; p = p + 1; printf("%u", p); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { float * p; p = (float*) 100; p = p + 1; printf("%u", p); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int* p; p = (int*) 100; p = p * 1; printf("%u", p); return 0; }
pointers c interview questions for fresher
What is the output of the following program?
#include<stdio.h> int main() { int* p, * q; p = (int*) 100; q = (int*) 200; p = p + q; printf("%u", p); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int*p, *q; p = (int*)100; q = (int*)200; printf("%u",q - p); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { float * p, * q; p = (float*) 100; q = (float*) 200; printf("%u", q - p); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { void*p; void far* q; printf("\n%u", sizeof(p)); printf("\n%u", sizeof(q)); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { void a; printf("\n%u", sizeof(a)); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { const int a = 5; printf("\n%d", a); a++; printf("\n%d", a); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int* p; const int a = 5; p = & a; * p = 6; printf("%d", a); return 0; }
c pointers interview questions
What is the output of the following program?
#include<stdio.h> int main() { int a = 5; const int* p=&a; *p = 6; printf("%d", *p); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int a = 5; int const*p = &a; *p = 6; printf("%d", *p); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int a = 5; int* const p = & a; *p = 6; printf("%d", *p); return 0; }
What is the output of the following program?
#include<stdio.h> int main() { int a = 89; int p; p = & a; *(int*)p = 8; printf("\na =%d", a); return 0; }
- int* p; in the above declaration ‘*’ is_______
What is the output of the following program?
#include<stdio.h> int main() { double* p = (double*)1000; p = p + 3; printf(" %u", p); }
What is the output of the following program?
#include<stdio.h> int main() { int* p = (int*)1000; int* temp; temp = p; p = p + 2; printf("%u %u\n", temp, p); printf("difference= %d", p - temp); }
What is the output of the following program?
#include<stdio.h> int main() { float* p = (float*)1000; float* q = (float*)2000; printf("Difference= %d", q - p); }
What is the output of the following program?
#include <stdio.h> int main() { int i = 5; int* p = & i; int* q = (int*) 2; printf("%d", p + q); }
What is the output of the following program?
#include <stdio.h> int main() { int near* p = (int near*) 0x0A0005555; int near* q = (int near*) 0x0A2115555; if (p == q) printf("Equql"); else printf("Not equal"); }
What is the output of the following program?
#include <stdio.h> int main() { int far* p = (int far*) 0x0A0005555; int far* q = (int far*) 0x0A2115555; if (p == q) printf("Equql"); else printf("Not equal"); }
What is the output of the following program?
#include <stdio.h> int main() { int huge* p = (int huge* ) 0x0A0005555; int huge* q = (int huge* ) 0x0A2113445; if (p == q) printf("Equql"); else printf("Not equal"); }
What is the output of the following program?
#include <stdio.h> int main() { int i = 5, j = 10; int* p = &i; int* q = &j; printf("%d", p | q); }
What is the output of the following program?
#include <stdio.h> int main() { int near* far *huge* p; printf("%d", sizeof(p)); printf(" %d", sizeof( *p)); printf(" %d", sizeof( **p)); }
What is the output of the following program?
#include<stdio.h> int main() { int a = 320; char* ptr; ptr = (char*) & a; printf("%d ", *ptr); }
What is the output of the following program?
#include<stdio.h> int main() { char huge* p = (char*) 0XC0563331; char huge* q = (char*) 0XC2551341; if (p == q) printf("Equal"); else if (p > q) printf("Greater than"); else printf("Less than"); return 0; }
- What is the size of a generic pointer in c?
What is the output of the following program?
#include<stdio.h> int main() { int i = 5; int* p; p = & i; printf(" %u %u", *&p, &*p); }
What is the output of the following program?
#include<stdio.h> int main() { int i = 5, j; int*p, *q; p = & i; q = & j; j = 5; printf("value of i : %d value of j : %d", *p, *q); getch(); }
What is the output of the following program?
#include<stdio.h> int main() { int* p, b; b = sizeof(p); printf(" % d", b); }
What is the output of the following program?
#include<stdio.h> int main() { int a = 5, b = 10, c; int* p = & a, *q = & b; c = p - q; printf("%d", c); }
What is the output of the following program?
#include<stdio.h> int main() { int a, b, c, d; char* p = (char*) 0; int* q = (int*) 0; floa* r = (float*) 0; double* s = (double*) 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); }
What is the output of the following program?
#include<stdio.h> int main() { int register a; scanf("%d", &a); printf("%d", a); } //if a=25
What is the output of the following program?
#include<stdio.h> int main() { char far *p, *q; printf("%d %d", sizeof(p), sizeof(q)); }
What is the output of the following program?
#include<stdio.h> int main() { int a = 10; void * p = & a; int* ptr = p; printf("%u", * ptr); }
What is the output of the following program?
#include<stdio.h> int main() { register a = 25; int far* p; p = &a; printf("%d ", * p); }
What is the output of the following program?
#include <stdio.h> int main() { int i = 100; void* ptr; ptr = (int*) & i; printf("\n % u % u", & i, (int*)ptr); printf("\n % d % d", i, *(int*)ptr); }
What is the output of the following program?
#include <stdio.h> int main() { float f = 17.0; void* ptr; ptr = (float*) & f; printf("\n % d % d", sizeof(i), sizeof(ptr)); printf("\n % d % d", i, *(int*) ptr); }