Character Array MCQ 12 : String



Character Array MCQ 12 : Random Address


What is the Output of the Following Program ?

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

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

printf("%s ",&str[2]);
printf("%s ",str);
printf("%s ",&str);

return(0);
}

Options :

  1. ogramming Programming Programming
  2. ogramming Programming < Garbage Value >
  3. Programming ogramming Programming
  4. Program Compiled with Syntax Errors

Output:


Switch to String MCQ Home : Click Here


Note:
  • &str[2]” means Memory Address of str[2]
  • “Address of str[2] acts as “Base Address” and it prints string From str[2] Onwards.
  • While Loading Address “str[0]” or “str” or “&str” contain Same Address.