Programs on string manipulations in C

/*
Author : ITVoyagers (https://itvoyagers.in/)

Date :25th December 2018

Description : Programs on string manipulations.
*/

#include<stdio.h>
#include<string.h>
void main()
{
    char a[]="ITVoyagers",b[10];
    char s[10],d[10];
    int x=strlen(a);
    clrscr();

    printf("strlen(a): %dn",x);
    strcpy(b,a);
    printf("strcpy(b,a): %sn",b);
    x=strcmp(a,b);
    printf("strcmp(a,b): %dn",x);
    printf("strupr(a): %sn",strupr(a));
    printf("strlwr(a): %sn",strlwr(a));
    printf("strrev(a): %sn",strrev(a));
    strcat(a,b);
    printf("strcat(a,b): %sn",a);
    printf("nPalindrome with string functionsn");

    printf("nEnter a string: ");
    scanf("%s",&s);
    strcpy(d,s);
    strrev(s);
    if(strcmp(d,s)==0)
    {
        printf("nEntered string is a Palindromen");
    }
    else
    {
        printf("nEntered string is not a Palindromen");
    }
    getch();
}

Output:

strlen(a): 10
strcpy(b,a): ITVoyagers
strcmp(a,b): 0
strupr(a): ITVOYAGERS
strlwr(a): itvoyagers
strrev(a): sregayovti
strcat(a,b): sregayovti ITVoyagers

Palindrome with string functions

Enter a straing: ITVoyagers

Entered string is not a Palindrome

Leave a Comment