Strings


  1. Read the following program.
    findPalindrome
    {
    char *str;
    char *str1;
    str = str1;
    while(str1 != NULL)
     {
       str1++;
     }
    while(str!=NULL)
    {
       if(str1--!= str++)
       {
        printf("Not palindrome");
        return
      }
    }
    printf("Palindrome");
    }
    
    This function will work correctly for which string?









  1. View Hint View Answer Discuss in Forum

    example of an odd palindrome:-
    madam
    Level
    example of an even palindrome:-
    noon

    Correct Option: C

    take example of string "madam" for odd palindrome.
    str points to beginning of the string 'm'
    str1 points to end of string 'm'
    1st iteration, it is equal.
    2nd iteration - 'a'
    3rd iteration - 'd'
    4th iteration - 'a'
    5th iteration - 'm'

    similarly consider even palidrome string:- "noon"

    str points to beginning of the string 'n'
    str1 points to end of string 'n'
    2nd iteration-'o'
    3rd iteration-'o'
    4th iteration-'n'

    It works for both even and odd palindromes


  1. Which of the following will return a non-zero value when checked with isspace(c)?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    All of above



  1. What will be the output of the following C code?
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {
    char n = 20;
    if (isdigit(n))
    {
    printf("Digit\n");
    }
    else
    {
    printf("Not Digit\n");
    }
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Not Digit


  1. What will be the output of the following C code?
    #include <stdio.h>
    #include <ctype.h>
    int main()
    {
    int n = 'B';
    if (isdigit(n))
    {
    printf("Digit\n");
    }
    else
    {
    printf("Not Digit\n");
    }
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Not Digit



  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    char n = '25';
    if (isdigit(n))
    {
    printf("Digit\n");
    }
    else
    {
    printf("Not Digit\n");
    }
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Digit