Character Array MCQ 13 : Printing Initialized Array



Character Array Multiple Choice Question  13 : Printing Initialized Array


What is the Output of the Following Program ?

#include<stdio.h>
#include<string.h>

int main()
{
char str[2] = "A";

printf("n%c",&str[0]);
printf("t%s",str);

return(0);
}

Options :

  1. A Garbage
  2. Garbage A
  3. Garbage Garbage
  4. A A

Output:


Switch to String MCQ Home : Click Here


Note:
  • Refer Our Article : [Initializing String]
  • In this Type of Initialization “\0” is not Compulsory .
  • So This Initialization is Perfectly Legal. It will Prints “A”.
  • First Character is Also “A”.