Skip to content

Beta · Data may be lost.Your data may be reset or lost.

GateBrew
← GATE CSE 2017 Set 1
Questions

Q53

NAT2 marksProgrammingMedium

Consider the following C program.

#include<stdio.h>
#include<string.h>
void printlength(char *s, char *t) {
    unsigned int c=0;
    int len = ((strlen(s) - strlen(t)) > c) ? strlen(s) : strlen(t);
    printf("%d\n", len);
}
void main() {
    char *x = "abc";
    char *y = "defgh";
    printlength(x,y);
}

Recall that strlenstrlen is defined in string.hstring.h as returning a value of type size_tsize\_t, which is an unsigned int. The output of the program is __________ .

Sign in to save attempts.

Solutions and discussion are hidden while you attempt this question. They open once you check or show the answer.