Exercise questions - Strings

Solve the following program without using string function

  1. Input string and find length
  2. Convert into lower/upper case
  3. Reverse the string
  4. Copy string
  5. Append string

Solve the following program, using string function

  1. Input 'ANKIT'
    Output:
    A
    AN
    ANK
    ANKI
    ANKIT
  2. Input two strings and swap.
  3. Solution: C

  4. Input string and find string is palindrome or not.
  5. void main()
    {
        char n[50], n2[50];
        printf("Enter name");
        gets(n);
        
        strcpy(n2,n);
        strrev(n2);
        
        if(strcmp(n,n2)==0)
        {
            printf("String is Palendrome");
        }
        else
        {
            printf("String is Not Palendrome");
        }
    }
  6. Input string and count number of vowels.
  7. Solution: C

  8. Input string and count blank spaces, characters and words.
  9. Trim all the spaces in between the sentence.
  10. Solution: C

  11. Replace 2 or more blank spaces with a single blank space.
  12. Solution: C

  13. Input main string and a sub-string, WAP to find a sub-string from a main string.
  14. Input username and password and check it, username is not case-sensitive, but password is case-sensitive.