-->

WAP to replace all white spaces with a character.

in turboc++
---------------------------------------------------------------------------------
//program to replace all white space with a character.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char string[100],sec;
    int i;
    printf("enter first string\n");
    gets(string);//accepts string
    printf("enter a character\n");
    sec=getchar();//accpts a character
    printf("before replacing,string is %s\n",string);
    for(i=0;string[i]!='\0';i++)//loop execution till null character
    {
        if(string[i]==' ')//condition testing for white space
        {
            string[i]=sec;//assigning character
        }
    }
    printf("after replacing, the string=%s",string); //prints the string.
  getch(); 
  return 0;
}
----------------------------------------------------------------------------------
in codeblocks:
-----------------------------------------------------------------------------
//program to replace all white space with a character.
#include <stdio.h>
#include<string.h>
int main()
{
    char string[100],sec;
    int i;
    printf("enter first string\n");
    gets(string);//accepts string
    printf("enter a character\n");
    sec=getchar();//accpts a character
    printf("before replacing,string is %s\n",string);
    for(i=0;string[i]!='\0';i++)//loop execution till null character
    {
        if(string[i]==' ')//condition testing for white space
        {
            string[i]=sec;//assigning character
        }
    }
    printf("after replacing, the string=%s",string); prints the string.
    return 0;
}




program to swap two strings

in turboc++
--------------------------------------------------------------------------------------------------
//program to swap two strings
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char string[100],string1[100],tempo[100];
    printf("enter first string\n");
    gets(string);//accepts string
    printf("enter second string\n");
    gets(string1);
    printf("before swapping,strings are=%s and %s\n",string,string1);
    strcpy(tempo,string);//copies string to another
    strcpy(string,string1);//copies to string
    strcpy(string1,tempo);//copies string to string1

    printf("after swapping,strings are=%s and %s\n",string,string1);
     getch();
    return 0;
}
----------------------------------------------------------------------------------
in codeblocks
----------------------------------------------------------------------------------------------------
//program to swap two strings
#include <stdio.h>
#include<string.h>
int main()
{
    char string[100],string1[100],tempo[100];
    printf("enter first string\n");
    gets(string);//accepts string
    printf("enter second string\n");
    gets(string1);
    printf("before swapping,strings are=%s and %s\n",string,string1);
    strcpy(tempo,string);//copies string to another
    strcpy(string,string1);//copies to string
    strcpy(string1,tempo);//copies string to string1

    printf("after swapping,strings are=%s and %s\n",string,string1);

    return 0;
}

Program to know a string is Palindrome or not

in turboc++
------------------------------------------------------------------------------------------------------
//program to know a string is Palindrome or not
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char string[100],string1[100];
    printf("enter string\n");
    gets(string);//accepts string
    strcpy(string1,string);//copies string to another
    strrev(string);//reverses the string
    if((strcmp(string,string1)==0))//compares the strings are same or not
    {
        printf("it is palindrome");

    }
    else
    {
        printf("it is not palidrome");
    }

     getch();
    return 0;
}
--------------------------------------------------------------------------------------------------
in codeblocks:
--------------------------------------------------------------------------------------------------
//program to know a string is Palindrome or not
#include <stdio.h>
#include<string.h>
int main()
{
    char string[100],string1[100];
    printf("enter string\n");
    gets(string);//accepts string
    strcpy(string1,string);//copies string to another
    strrev(string);//reverses the string
    if((strcmp(string,string1)==0))//compares the strings are same or not
    {
        printf("it is palindrome");

    }
    else
    {
        printf("it is not palidrome");
    }


    return 0;
}

WAp to reverse a string without using strrev function().

in turboc++
---------------------------------------------------------------------------------------------------------
//WAp to reverse a string without using strrev function().

#include <stdio.h>
#include<conio.h>
int main()
{
    char string[100];
    int i;
    printf("enter string\n");
    gets(string);
    for(i=0;string[i]!='\0';i++);//no body line; takes the last value of i.
 
    for(int j=i;string[j]>=0;j--)//loop runs in reverse order.
    printf("%c",string[j]);//prints the charcater.

    return 0;
}






-------------------------------------------------------------------------------------------------------------
in codeblocks
------------------------------------------------------------------------------------------

///WAp to reverse a string without using strrev function().

#include <stdio.h>

int main()
{
    char string[100];
    int i;
    printf("enter string\n");
    gets(string);
    for(i=0;string[i]!='\0';i++);//no body line; takes the last value of i.
 
    for(int j=i;string[j]>=0;j--)//loop runs in reverse order.
    printf("%c",string[j]);//prints the characater.

    return 0;
}
--------------------------------------------------------------------------------------------------
or
---------------------------------------------------------------------------------
/WAp to reverse a string without using strrev function().

#include <stdio.h>

int main()
{
    char string[100];
    int i,count=0;
    printf("enter string\n");
    gets(string);
    for(i=0;string[i]!='\0';i++)
{
      count++;
}
 
    for( i=count;string[i]>=0;i--)//loop runs in reverse order.
    printf("%c",string[i]);//prints the characater.

    return 0;
}



--------------------------------------------------------------------------------------------------------------------

WAP to find length of string without strlen() function.

using turbo c++
----------------------------------------------------------------------------------------------------------------
//wap to find the lenght of given string with out strlen()
#include <stdio.h>
#include<conio.h>
int main()
{
    char string[100];
    int count=0,i;
    printf("enter string\n");
    gets(string);
    for(i=0;string[i]!='\0';i++)
    {
        count++;
    }
    printf("length=%d",count);
    getch();
    return 0;
}






-------------------------------------------------------------------------------
using codeblocks
------------------------------------------------------------------------------------------------------------
//wap to find the lenght of given string
#include <stdio.h>

int main()
{
    char string[100];
    int count=0,i;
    printf("enter string\n");
    gets(string);
    for(i=0;string[i]!='\0';i++)
    {
        count++;
    }
    printf("length=%d",count);

    return 0;
}



or

------------------------------
//wap to find the lenght of given string
#include <stdio.h>

int main()
{
    char string[100];
    int i;
    printf("enter string\n");
    gets(string);
    for(i=0;string[i]!='\0';i++);// loop execution.; no body line; it just takes last value of i.
   
    printf("length=%d",i);

    return 0;
}


WAP to compare two strings using strcmp() function.

using turboc++
---------------------------------------------------------------------------------------------------------------------
//WAP to compare  two strings  using(strcmp()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char st[100],st1[100];//two string declaration
    printf("enter first string\n");
    gets(st);
    printf("enter second string\n");
     gets(st1);//inputs
    if(strcmp(st,st1)>0)//
    {
        printf("%s has more ascii value than %s",st,st1);
    }
    else if(strcmp(st,st1)<0)
    {
        printf("%s has more ascii value than %s",st1,st);

    }
    else
    {
        printf("%s and %s have same ascii value",st,st1);
    }
getch();
    return 0;
}


---------------------------------------------------------------------------------------
using codeblocks
------------------------------------------------------------------------------------------------
//WAP to compare  two strings  using(strcmp()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1[100];//two string declaration
    printf("enter first string\n");
    gets(st);
    printf("enter second string\n");
     gets(st1);//inputs
    if(strcmp(st,st1)>0)//
    {
        printf("%s has more ascii value than %s",st,st1);
    }
    else if(strcmp(st,st1)<0)
    {
        printf("%s has more ascii value than %s",st1,st);

    }
    else
    {
        printf("%s and %s have same ascii value",st,st1);
    }
    return 0;
}


WAP to concatenate /merge two strings using strcat() function.

using turboc++
--------------------------------------------------------------------------------------------------
//WAP to merge  two strings  using(strcat()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char st[100],st1[100];//two string declaration
    printf("enter first string\n");
    gets(st);
    printf("enter second string\n");
     gets(st1);//inputs
    strcat(st,st1);//merging st1 string into first (st)
    printf("merged string =%s\n",st);//prints the merged strings(st)
   getch();
    return 0;
}


---------------------------------------------------------------------------------------------------
using codeblocks
----------------------------------------------------------------------------------------------------
//WAP to merge  two strings  using(strcat()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1[100];//two string declaration
    printf("enter first string\n");
    gets(st);
    printf("enter second string\n");
     gets(st1);//inputs
    strcat(st,st1);//merging st1 string into first (st)
    printf("merged string =%s\n",st);//prints the merged strings(st)
    return 0;
}