Pointer and Structure in C · Programming Languages · GATE CSE
Start PracticeMarks 1
GATE CSE 2024 Set 2
Consider the following C function definition. int fX(char *a) {
char *b = a;
while(*b)
b++;
return b - a; } Which of the fol...
GATE CSE 2022
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 ...
GATE CSE 2021 Set 2
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...
GATE CSE 2019
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;
...
GATE CSE 2018
Consider the following C program.
#include< stdio.h >
struct Ournode{
char x,y,z;
};
int main(){
struct Ournode p = {'1', '0', 'a'+2};
struct...
GATE CSE 2016 Set 1
Consider the following C program
void f(int, short);
void main()
{
int i = 100;
short s = 12;
short *p = &s;
__________ ; // ca...
GATE CSE 2016 Set 1
Consider the following C program.
#include < stdio.h >
void mystery(int *ptra, int *ptrb) {
int *temp;
temp = ptrb;
ptrb = ptra;...
GATE CSE 2015 Set 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=*...
GATE CSE 2011
What does the following fragment of C-program print?
char c[ ] = "GATE2011";
char *p = c;
printf("%s", p + p[3] - p[1]);
GATE CSE 2010
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 ( ){
...
GATE CSE 2005
What does the following C statement declare?
int (*f)(int *);
GATE CSE 2004
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 tw...
GATE CSE 2003
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 wil...
GATE CSE 2000
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
...
GATE CSE 2000
Consider the following C declaration
struct {
short s[5];
union {
float y;
long z;
} u;
}t;
Assume that objects of the t...
GATE CSE 2000
The following C declarations
struct node{
int i:
float j;
};
struct node *s[10];
define s to be
Marks 2
GATE CSE 2024 Set 2
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;
pri...
GATE CSE 2021 Set 2
Consider the following ANSI C program:
#include <stdio.h>
#include <stdlib.h>
struct Node{
int value;
struct Node ⋆next;};
int ...
GATE CSE 2019
Consider the following C program:
#include < stdio.h >
int main()
{
int a[] = {2, 4, 6, 8, 10} ;
int ...
GATE CSE 2018
Consider the following C program:
#include< stdio.h >
void fun1(char *s1, char *s2){
char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
void fun2...
GATE CSE 2015 Set 1
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 (...
GATE CSE 2012
Consider the following C code segment.
int a, b, c = 0;
void prtFun(void);
main( )
{
static int a = 1; /* Line 1 */
prtFun();
a + = 1;
pr...
GATE CSE 2012
Consider the following C code segment.
int a, b, c = 0;
void prtFun(void);
main( )
{
static int a = 1; /* Line 1 */
prtFun();
a + = 1;
pr...
GATE CSE 2008
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;
...
GATE CSE 2006
Consider this C code to swap two integers and these five statements:
void swap(int *px, int *py)
{
*px = *px - *py;
*py = *px + *py;
*...
GATE CSE 2004
Consider the following C program segment:
char p[20];
char *s = "string";
int length = strlen(s);
for(i=0; i < length; i++)
p[i] = s[length-i];
p...
GATE CSE 2003
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(...
GATE CSE 2001
Consider the following three C functions:
[P1] int*g(void)
{
int x=10;
return(&x);
}
[P2] int*g(void)
{
int...
Marks 5
GATE CSE 2001
Consider the following C program:
void abc(char *s)
{
if(s[0]=='\0') return;
abc(s+1);
abc(s+1);
printf("%c",s[0]);
}
main()
{
abc("12...