-->

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

in turboc++
-----------------------------------------------------------------------------------------
//WAP to concatenate  two strings  without using(strcat()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char st[100],st1[100];//two string declaration
    int i,j;
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//to input string with space
    scanf("%s",st); //it also CAN BE USED. IT accepts string with space until it meets new line
    printf("enter second string\n");
    scanf("%s",st1);
     for(i=0;st[i]!='\0';i++);//to get last value of i of first string
    for(j=0;st1[j]!='\0';j++)//loop execution till null character
    {

        st[i]=st1[j];//copying characters
        i++;
    }

    st[i]='\0';//adds an extra null character at the end.

       printf("concatenated string =%s\n",st);//prints the merged string
   getch();
    return 0;
}
---------------------------------------------------------------------------------------------------------
in codeblocks:
-----------------------------------------------------------------------------------------
//WAP to concatenate  two strings  without using(strcat()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1[100];//two string declaration
    int i,j;
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//to input string with space
    scanf("%s",st); //it also CAN BE USED. IT accepts string with space until it meets new line
    printf("enter second string\n");
    scanf("%s",st1);
     for(i=0;st[i]!='\0';i++);//to get last value of i of first string
    for(j=0;st1[j]!='\0';j++)//loop execution till null character
    {

        st[i]=st1[j];//copying characters
        i++;
    }

    st[i]='\0';//adds an extra null character at the end.

       printf("concatenated string =%s\n",st);//prints the merged string
    return 0;
}

WAP to copy a string without using strcpy().

in turboc++
---------------------------------------------------------------------------------------------------------
//WAP to copy  a string  without using(strcpy()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char st[100],st1[100];//two string declaration
    int i;
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//to input string with space
    scanf("%[^\n]s",st); //it also CAN BE USED. IT accepts string with space until it meets new line
    for(i=0;st[i]!='\0';i++)//loop execution till
    {
        st1[i]=st[i];//copying characters
    }

    st1[i]='\0';//adds an extra null character at the end.

       printf("copied string =%s\n",st1);//prints the name in lowercase
     getch();
    return 0;
}

------------------------------------------------------------------------------------------------------
in codeblocks
------------------------------------------------------------------------
//WAP to copy  a string  without using(strcpy()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1[100];//two string declaration
    int i;
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//to input string with space
    scanf("%[^\n]s",st); //it also CAN BE USED. IT accepts string with space until it meets new line
    for(i=0;st[i]!='\0';i++)//loop execution till
    {
        st1[i]=st[i];//copying characters
    }

    st1[i]='\0';//adds an extra null character at the end.

       printf("copied string =%s\n",st1);//prints the name in lowercase
    return 0;
}


WAP to convert given string into lowercase without using strlwr() function.

in turboc++
--------------------------------------------------------------------------------------------------
//program to convert given string into lowercase without strlwr()
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
int main()
{
    char string[100];
    int i;
    printf("enter a string in uppercase\n");
    gets(string);//INPUT
    for(i=0;string[i]!='\0';i++)//LOOP EXECUTION
    {
        if(string[i]!=' ')//CONDITION TESTING
        printf("%c",string[i]+32);//CONVERTING INTO LOWERCASE BY ADDING 32
        else
            printf(" ");//PRINTING SPACE
    }
    getch();
    return 0;
}


--------------------------------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------------------------------------------------------------
//program to convert given string into lowercase without strlwr()
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char string[100];
    int i;
    printf("enter a string in uppercase\n");
    gets(string);//INPUT
    for(i=0;string[i]!='\0';i++)//LOOP EXECUTION
    {
        if(string[i]!=' ')//CONDITION TESTING
        printf("%c",string[i]+32);//CONVERTING INTO LOWERCASE BY ADDING 32
        else
            printf(" ");//PRINTING SPACE
    }
    return 0;
}

WAP to convert given string into uppercase without using strupr() function.

in turboc++
----------------------------------------------------------------------------------
//program to convert given string into uppercase without strupr()
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
int main()
{
    char string[100];
    int i;
    printf("enter a string in lowercase\n");
    gets(string);//INPUT
    for(i=0;string[i]!='\0';i++)//LOOP EXECUTION
    {
        if(string[i]!=' ')//CONDITION TESTING
        printf("%c",string[i]-32);//CONVERTING INTO UPPERCASE BY subtracting 32
        else
            printf(" ");//PRINTING SPACE
    }
   getch();
    return 0;
}
------------------------------------------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------------------------------------------------
//program to convert given string into uppercase without strupr()
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char string[100];
    int i;
    printf("enter a string in lowercase\n");
    gets(string);//INPUT
    for(i=0;string[i]!='\0';i++)//LOOP EXECUTION
    {
        if(string[i]!=' ')//CONDITION TESTING
        printf("%c",string[i]-32);//CONVERTING INTO UPPERCASE BY subtracting 32
        else
            printf(" ");//PRINTING SPACE
    }
    return 0;
}

WAP to scan first string for the first occurrence of the substring in string second using strstr() function.

in turboc++
-------------------------------------------------------------------------------------------------------
//program to understand strstr() function
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
int main()
{
    char name[100],string[100];
    printf("enter string\n");
    gets(name);//gets the string
    printf("enter string to be searched\n");
    gets(string);//gest the string to be searched and to be printed from.
    printf("substrig=%s\n",strstr(name,string));//prints the characters from input string
    getch();
    return 0;
}
/*
note:-
It prints the string from occurrence of first character.
e.g
abcdefg
c
it will print all the letters starting from 'c'
*/


-----------------------------------------------------------------------------
in codeblocks
--------------------------------------------------------------------------------------
//program to understand strstr() function
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char name[100],string[100];
    printf("enter string\n");
    gets(name);//gets the string
    printf("enter string to be searched\n");
    gets(string);//gest the string to be searched and to be printed from.
    printf("substrig=%s\n",strstr(name,string));//prints the characters from input string
    return 0;
}
/*
note:-
It prints the string from occurrence of first character.
e.g
abcdefg
c
it will print all the letters starting from 'c'
*/


WAP to find initial segment of string that consists entirely of characters from second string. using strspn() function.

in turboc++
--------------------------------------------------------------------------------------------------------------
//WAP to  know location of difference of string (segment)in another string using  strspn() function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char st[100],st1[100];// declaration
    printf("enter  string\n");
    gets(st);
    printf("enter second string\n");
     gets(st1);//inputs
    strspn(st,st1);
    printf("location of difference=%d\n",strspn(st,st1));//prints the location from where segment is //different
   getch();
    return 0;
}

-------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------------
//WAP to  know location of difference of string (segment)in another string using  strspn() function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1[100];// declaration
    printf("enter  string\n");
    gets(st);
    printf("enter second string\n");
     gets(st1);//inputs
    strspn(st,st1);
    printf("location of difference=%d\n",strspn(st,st1));//prints the location from where segment is different
    return 0;
}

WAP to set all characters in the given string to the character using strset() function.

in turboc++
----------------------------------------------------------------------------------------
//WAP to  string with other character  using(strset()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char st[100],st1;// declaration
    printf("enter  string\n");
    gets(st);
    printf("enter a character to set for\n");
     st1=getchar();//inputs
    printf("string before setting=%s\n",st);
    strset(st,st1);
    printf("string after setting with character=%c is =%s\n",st1,st);
    getch();
    return 0;
}
-------------------------------------------------------------------------------------------
in codeblocks:
-----------------------------------------------------------------------------------------
//WAP to  string with other character  using(strset()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1;// declaration
    printf("enter  string\n");
    gets(st);
    printf("enter a character to set for\n");
     st1=getchar();//inputs
    printf("string before setting=%s\n",st);
    strset(st,st1);
    printf("string after setting with character=%c is =%s\n",st1,st);
    return 0;
}