C Programming 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

Q63

GATE CS 2025 CS-1C ProgrammingNAT2 marks
Consider the following C program:
#include <stdio.h>
int gate (int n) {
 int d, t, newnum, turn;
 newnum = turn = 0; t=1;
 while (n>=t) t *= 10;
 t /=10;
 while (t>0) {
 d = n/t;
 n = n%t;
 t /= 10;
 if (turn) newnum = 10*newnum + d;
 turn = (turn + 1) % 2;
 }
 return newnum;
}
int main () {
 printf ("%d", gate(14362));
 return 0;
}
The value printed by the given C program is _______ . (Answer in integer)
Show answer without attempting

Answer: 46

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

Q33

GATE CS 2025 CS-2C ProgrammingNAT1 mark
 int x=126,y=105;
 do {
 if(x>y) x=x-y;
 else y=y-x;
 } while(x!=y);
 printf("%d",x);
The output of the given C code segment is ________. (Answer in integer)
Show answer without attempting

Answer: 21

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/50 correct0 marks

Related topics in Programming and Data Structures