GATE CS 2017 (Forenoon) — Question 53

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

Consider the following C program.
c
1#include <stdio.h>
2#include <string.h>
3void printlength (char *s, char *t) {
4    unsigned int c = 0;
5    int len = ((strlen(s) - strlen(t)) > c) ? strlen(s): strlen(t);
6    printf("%d\n", len);
7}
8void main ( ) {
9    char *x = "abc";
10    char *y = "defgh";
11    printlength (x, y);
12}
13
Recall that strlen is defined in string.h as returning a value of type size_t, which is an unsigned int. The output of the program is ________.
Practise the full 2017-FN paper
Challenge a friend: WhatsApp Telegram
From RENYXERAWhat rank do your marks get?GATE score, likely All-India Rank and qualifying marks for your category.
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