434 views
2 votes
2 votes
int main()
{
        char str[10]="GATE2018";
        int length=strlen(str);
        str[length]='\0';
        for(i=0;str[i];i++)
        printf("%c",str[i]);
        return 0;
}

Find the output?       

2 Answers

Best answer
3 votes
3 votes
-> we have to add int i;

-> strlen(str) will return 8

->BUT  S[8] is already null // array starts from 0,

So, GATE2018 is answer
selected by
2 votes
2 votes
On execution of the above program gives output as:

GATE2018​​​​​​​

No related questions found