First1Last
1 of 1 pages
  1. A
    strinit()

    B
    strnset()

    C
    strset()

    D
    strcset()

    Explanation: char *strnset(char *s, int ch, size_t n); Sets the first n characters of s to ch
    #include <stdio.h>
    #include <string.h>
    
    int main(void)
    {
       char *string = "abcdefghijklmnopqrstuvwxyz";
       char letter = 'x';
    
       printf("string before strnset: %s\n", string);
       strnset(string, letter, 13);
       printf("string after  strnset: %s\n", string);
    
       return 0;
    }
    
    Output: string before strnset: abcdefghijklmnopqrstuvwxyz string after strnset: xxxxxxxxxxxxxnopqrstuvwxyz 

    1. Twitter
    2. Google+
  2. A
    -1

    B
    1

    C
    0

    D
    Yes

    Explanation: Declaration: strcmp(const char *s1, const char*s2); The strcmp return an int value that is if s1 < s2 returns a value < 0 if s1 == s2 returns 0 if s1 > s2 returns a value > 0 

    1. Twitter
    2. Google+
  3. A
    printf("\n");

    B
    echo "\\n";

    C
    printf('\n');

    D
    printf("\\n");

    Explanation: The statement printf("\\n"); prints '\n' on the screen. 

    1. Twitter
    2. Google+
  4. A
    strnstr()

    B
    aststr()

    C
    strrchr()

    D
    strnset()

    Explanation: he function strstr() Finds the first occurrence of a substring in another string Declaration: char *strstr(const char *s1, const char *s2); Return Value: On success, strstr returns a pointer to the element in s1 where s2 begins (points to s2 in s1). On error (if s2 does not occur in s1), strstr returns null. Example:
    #include <stdio.h>
    #include <string.h>
    
    int main(void)
    {
       char *str1 = "VCampus", *str2 = "mp", *ptr;
    
       ptr = strstr(str1, str2);
       printf("The substring is: %s\n", ptr);
       return 0;
    }
    
    Output: The substring is: mpus 

    1. Twitter
    2. Google+
  5. A
    printf();

    B
    scanf();

    C
    gets();

    D
    puts();

    Explanation: gets(); collects a string of characters terminated by a new line from the standard input stream stdin
    #include &lt;stdio.h&gt;
    
    int main(void)
    {
       char string[80];
    
       printf(&quot;Enter a string:&quot;);
       gets(string);
       printf(&quot;The string input was: %s\n&quot;, string);
       return 0;
    }
    
    Output: Enter a string: IndiaBIX The string input was: IndiaBIX 

    1. Twitter
    2. Google+
  6. A
    int xstrlen(char *s)
    {
        int length=0;
        while(*s!='\0')
        {    length++; s++; }
        return (length);
    }
    

    B
    int xstrlen(char s)
    {
        int length=0;
        while(*s!='\0')
            length++; s++;
        return (length);
    }
    

    C
    int xstrlen(char *s)
    {
        int length=0;
        while(*s!='\0')
            length++;
        return (length);
    }
    

    D
    int xstrlen(char *s)
    {
        int length=0;
        while(*s!='\0')
            s++;
        return (length);
    }
    

    Explanation: Option A is the correct function to find the length of given string. Example:
    #include<stdio.h>
    
    int xstrlen(char *s)
    {
        int length=0;
        while(*s!='\0')
        { length++; s++; }
        return (length);
    }
    
    int main()
    {
        char d[] = "VCampus";
        printf("Length = %d\n", xstrlen(d));
        return 0;
    }
    
     

    1. Twitter
    2. Google+
First1Last
1 of 1 pages