GATE CS 2025 (Forenoon) — Question 63

Programming in CData Types, Syntax, Control Structures, LoopsNAT2 marksMedium

Consider the following C program:
c
1#include <stdio.h>
2int gate (int n) {
3    int d, t, newnum, turn;
4    newnum = turn = 0; t = 1;
5    while (n >= t) t *= 10;
6    t /=10;
7    while (t > 0) {
8        d = n/t;
9        n = n%t;
10        t /= 10;
11        if (turn) newnum = 10*newnum + d;
12        turn = (turn + 1) % 2;
13    }
14    return newnum;
15}
16int main( ) {
17    printf ("%d", gate(14362));
18    return 0;
19}
20
The value printed by the given C program is ________. (Answer in integer)
Practise the full 2025-FN paper
Challenge a friend: WhatsApp Telegram
From RENYXERAPractise this subject in the exam simulatorTimed, GATE-style tests with analytics that find your weak topics.
Practise more on Data Types, Syntax, Control Structures, LoopsTimed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group