Strings

Q1: What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str[7] = "AptitudeCrack";
    printf("%s\n", str);
    return 0;
}

A Error

B AptitudeCrack

C Cannot predict

D None of above

ANS:C - Cannot predict

Here str[] has declared as 7 character array and into a 8 character is stored. This will result in overwriting of the byte beyond 7 byte reserved for '\0'.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.