Quiz


  1. Fill in the function name in the blank so that the output of the following code snippet is "YES" :
  2.     void myfunction{
          char word1[] = "India";
          char word2[] = "Free Country";
          word2 = ________(word2,word1);
          if(strcmp(word1,word2) == 0)
            printf("YES\n");
          else
            printf("NO\n");
        }
        
    a. strcat
    b. strlen
    c. strncat
    d. strcpy

  3. The name of the string is a (char *) pointer to the last character in the array.
  4. a. True
    b. False

  5. What will be the ouptut of the following code snippet?
  6.     char word[] = "Attitude";
        word[4] = '\0';
        int length = strlen(word);
        printf("%d\n",length);
    
        
    a. 8
    b. 7
    c. 4
    d. 3

  7. What will be the ouptut of the following code snippet?
  8.     char w[] = "india";
              w[5] = 'n';
              printf("%s\n",w);
        
    a. india
    b. indian
    c. segmentation fault
    d. none of the above

  9. What will the follwing function output if word is "heLlO_WOrLd !" ?
  10.     void func(char *word)
        {
          word[strlen(word)-1] = 'S';
          *(word + 3) = 'd';
          *(word + 5) = word[6] + 1;
              printf("%s\n",word);      
        }
        
    a. heldO_WOrLd S
    b. heLdOXWOrLd S
    c. heLlOXWorld !
    d. heLdO_World !