Functions and Pointers questions

Q34

GATE CS 2025 CS-1C ProgrammingNAT1 mark
#include <stdio.h>
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 __________. (Answer in integer)
Show answer without attempting

Answer: 25

Q19

GATE CS 2025 CS-2C ProgrammingMCQ1 mark−1/3 if wrong
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;
}
void stringcopy(char *s, char *t) {
    while(*t)
        *s++ = *t++;
}
Which ONE of the following will be the output of the program?
Show answer without attempting

Answer: D

Q62

GATE CS 2025 CS-2C ProgrammingNAT2 marks
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) + arr[1]);
    return 0;
}
The output of the above program is ___________. (Answer in integer)
Show answer without attempting

Answer: 111

0/30 correct0 marks

Related topics in C Programming