pointers
GATE CSE & IT · C Programming - Pointers and Strings · 1987-2026
Study anchor
Source-book anchor pending for this concept.
Practice action
Start latest PYQPYQs in this concept
All concepts →Consider the following ANSI-C program. #include <stdio.h> int main( ) { int *ptr, a, b, c; a=5; b=11; c=20; ptr=&a; *ptr=c; ptr=&c; a=*(&b); c=*ptr-a; printf("%d",c); return(0); }...
Consider the following C program: #include void stringcopy (char *, char *); int main() { char a [30] = "@#Hello World!"; stringcopy (a, a + 2); printf("%s\n", a); return 0; } void...
#include void foo(int *p, int x) { *p=x; } int main() { int *z; int a = 20, b = 25; z = &a; foo(z,b); printf("%d",a); return 0; } The output of the given C program is __________. (...
Consider the following C program: #include int main() { int a; int arr[5] = {30,50,10}; int *ptr; ptr = &arr[0] + 1; a = *ptr; (*ptr)++; ptr++; printf("%d", a + (*ptr) + arr[1]); r...
#include void foo(int *p, int x) { *p = x; } int main( ) { int *z; int a = 20, b=25; z = &a; foo(z, b); printf("%d", a); return 0; } The output of the given C program is _________....
Consider the following C program : #include <stdio.h> int main( ) { int a; int arr[5]={30,50,10}; int *ptr; ptr = &arr[0] + 1; a = *ptr; (*ptr)++; ptr++; printf("%d",a + (*ptr) + a...
Consider the following C program : #include <stdio.h> void stringcopy(char *, char *); int main( ) { char a[30] = "@#Hello world!"; stringcopy(a,a+2); printf("%s\n", a); return 0;...
Consider the following C function definition. int fX (char *a) { char *b = a; while (*b) b++; return b - a;} Which of the following statements is/are TRUE?
What is the output of the following C program? #include int main() { double a [2]={20.0, 25.0}, *p, *q; p = a; q = p + 1; printf("%d,%d", (int)(q - p), (int)(*q - *p)); return 0;}
Consider the following C function definition. int fX(char *a) { char *b = a; while(*b) b++; return b - a; } Which of the following statements is/are TRUE?
What is the output of the following C program? #include <studio.h> int main() { double a[2]={20.0, 25.0}, *p, *q; p = a; q = p + 1; printf("%d,%d", (int)(q - p), (int)(*q - *p)); r...
What is printed by the following ANSI C program? #include <stdio.h> int main(int argc, char *argv[ ]) { int x = 1, z[2] = {10, 11}; int *p = NULL; p = &x; *p = 10; p = &z[1]; *(&z[...
Consider the following ANSI C program. #include<stdio.h> int main(){ int arr[4][5]; int i, j; for(i =0; i<4; i++){ for (j =0; j<5; j++){ arr [i][j] = 10*i + j; } } print("%d", *(ar...
Consider the following ANSI C program: #include <stdio.h> #include <stdlib.h> struct Node{ int value; struct Node ⋆next;}; int main(){ struct Node ⋆boxE, ⋆head, ⋆boxN; int index =...
Consider the following C program. #include < stdio.h > int main () { int a [4] [5] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}}; printf (“%d\n”...
Consider the following C program : #include < stdio.h > int main () { int arr [] = {1,2,3,4,5,6,7,8,9,0,1,2,5}, *ip = arr+4; printf ("%d\n", ip[1]); return 0; } The number that wil...
Consider the following C program: #include < stdio.h > int main() { int a[] = {2, 4, 6, 8, 10} ; int i, sum = 0, *b = a + 4 ; for (i = 0; i < 5; i++) sum = sum + (*b - i) - *(b - i...
Consider the following C program. #include< stdio.h > struct Ournode{ char x,y,z; }; int main(){ struct Ournode p = {'1', '0', 'a'+2}; struct Ournode *q = &p; printf ("%c, %c", *((...
Consider the following C program: #include< stdio.h > void fun1(char *s1, char *s2){ char *tmp; tmp = s1; s1 = s2; s2 = tmp; } void fun2(char **s1, char **s2){ char *tmp; tmp = *s1...
Consider the following function implemented in C: void printxy(int x, int y) { int *ptr; x = 0; ptr = &x; y = *ptr; *ptr = 1; printf("%d,%d",x,y); } The output of invoking printxy...
Consider the following C Program. #include #include int main() { char* c = "GATECSIT2017"; char* p = c; printf("%d", (int)strlen(c+2[p]-6[p]-1)); return 0; } The output of the prog...
Consider the following C program. #include < stdio.h > void mystery(int *ptra, int *ptrb) { int *temp; temp = ptrb; ptrb = ptra; ptra = temp; } int main() { int a=2016, b=0, c=4, d...
Consider the following C program void f(int, short); void main() { int i = 100; short s = 12; short *p = &s; __________ ; // call to f() } Which one of the following expressions, w...
Consider the following function written in the C programming language. void foo(char *a){ if ( *a && *a != ' '){ foo(a+1); putchar(*a); } } The output of the above function on inpu...
What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an integer requires four bytes of memory. int main () { unsigned int x[4][3] = {{1...
The output of the following C program is__________. void f1(int a, int b) { int c; c=a; a=b; b=c; } void f2(int *a, int *b) { int c; c=*a; *a=*b; *b=c; } int main(){ int a=4, b=5,...
Consider the following C program segment. #include < stdio.h > int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = ‘0’; printf("%s", s1); } What will be printed by the program?
Consider the following program in C language: #include < stdio.h > main() { int i; int *pi = &i; scanf("%d", pi); printf("%d\n", i + 5); } Which one of the following statements is...
What does the following fragment of C-program print? char c[ ] = "GATE2011"; char *p = c; printf("%s", p + p[3] - p[1]);
The following C function takes a simply-linked list as input argument. It modifies the list by moving the last element to the front of the list and returns the modified list. Some...
What does the following program print? #include < stdio.h > void f (int *p, int *q) { p = q; *p = 2; } int i = 0, j = 1; int main ( ){ f(&i, &j); printf ("%d %d \ n", i, j); return...
The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers...
What is printed by the following C program? #include < stdio.h > int f(int x, int *py, int **ppz) { int y, z; **ppz += 1; z = **ppz; *py += 2; y = *py; x += 3; return x + y + z; }...
Consider this C code to swap two integers and these five statements: void swap(int *px, int *py) { *px = *px - *py; *py = *px + *py; *px = *py - *px; } S1: will generate a compilat...
What does the following C statement declare? int (*f)(int *);
The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers...
Consider the following C function: void swap (int a, int b) { int temp; temp = a; a = b; b = temp; } In order to exchange the values of two variables x and y.
Assume the following C variable declaration int * A[10], B[10][10]; Of the following expressions I. A[2] II. A[2] [3] III. B[1] IV. B[2] [3] Which will not give compile-time errors...
Consider the C program shown below. #include < stdio.h > #define print(x) printf("%d ", x) int x; void Q(int z) { z += x; print(z); } void P(int *y) { int x = *y+2; Q(x); *y = x-1;...
Consider the following three C functions: [P1] int*g(void) { int x=10; return(&x); } [P2] int*g(void) { int *px; *px = 10; return px; } [P3] int*g(void) { int *px px =(int*)malloc...
The following C declarations struct node{ int i: float j; }; struct node *s[10]; define s to be
The most appropriate matching for the following pairs $$X:$$ Indirect addressing $$Y:$$ Immediate addressing $$Z:$$ Auto decrement addressing is $$1:$$ Loops $$2:$$ Pointers $$3.$$...
The most appropriate matching for the following pairs X: m=malloc(5); m= NULL; Y: free(n); n->value = 5; Z: char *p; *p='a'; 1: using dangling 2: using uninitialized pointers 3. lo...
A certain processor supports only the immediate and the direct addressing modes. Which of the following programming language features cannot be implemented on this processor?
Indicate the following statement true or false : A programming language not supporting either recursion or pointer type does not need the support of dynamic memory allocation.
Match the pairs in the following: List - I (A) Pointer data type (B) Activation record (C) Repeat-until (D) Coercion List - II (p) Type conversion (q) Dynamic data structure (r) Re...
In a circular linked list organization,insertion of a record involves modification of :