-->

WAP to reverse a string using(strrev()) function.

using turbo c++
-------------------------------------------
//WAP to reverse a string using(strrev()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char name[100];//two dimensional declaration
    printf("enter string\n");
    //fgets(name, sizeof (name), stdin);
    scanf("%[^\n]s",name); //it also CAN BE USED. IT accepts string with space until it meets new line
    strrev(name);
    printf("reverse=%s\n",name);//prints the name
     getch();
    return 0;
}
-------------------------------------------------
in codeblocks
------------------------------------------------------
//WAP to reverse a string using(strrev()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char name[100];//two dimensional declaration
    printf("enter string\n");
    //fgets(name, sizeof (name), stdin);
    scanf("%[^\n]s",name); //it also CAN BE USED. IT accepts string with space until it meets new line
    strrev(name);
    printf("reverse=%s\n",name);//prints the name
    return 0;
}

//WAP to get /find length of string using(strlen()) function.

using turbo c++
--------------------------------------------------------------------------------------------
//WAP to get /find length of string using(strlen()) function.

#include <stdio.h>
#include<conio.h>
int main()
{
    char name[100];//two dimensional declaration
    int i,count=0;              //declaration with initialization
    printf("enter string\n");
    gets(name);
    for(i=0;name[i]!='\0';i++)//loop execution till it reaches \0 character
    {
        count++;            //counting goes on
    }
    printf("total length=%d\n",count);//prints the length
    getch();
     return 0;
}
-----------
or
---------------------
//WAP to get /find length of string using(strlen()) function.

#include <stdio.h>
#include<conio.h>
int main()
{
    char name[100];//two dimensional declaration
    int i;              //declaration with initialization
    printf("enter string\n");
    gets(name);
    for(i=0;name[i]!='\0';i++);//loop execution till it reaches \0 character; no body line.
    printf("total length=%d\n",i);//prints the length
    getch();
     return 0;
}

------------------------------------------------------------
using codeblocks:
-----------------------------------------------------------------------------
//WAP to get /find length of string using(strlen()) function.

#include <stdio.h>
int main()
{
    char name[100];//two dimensional declaration
    int i,count=0;              //declaration with initialization
    printf("enter string\n");
    gets(name);
    for(i=0;name[i]!='\0';i++)//loop execution till it reaches \0 character
    {
        count++;            //counting goes on
    }
    printf("total length=%d\n",count);//prints the length
   
     return 0;
}

/WAP to input any five names with address and display them.

using turboc++
------------------------------------------------------------
//WAP  to input any five names with address and display them.
#include <stdio.h>
#include<conio.h>
int main()
{
    char name[100][100];//two dimensional declaration
    char add[100][100];//two dimensional declaration
    int i,n;
    printf("enter n\n");
    scanf("%d",&n);
    printf("enter names and addresses\n");
    for(i=0;i<=n-1;i++)
    {
        printf("name \n");
        scanf("%s",name[i]);//gets inputs for name
        printf("address=\n");
        scanf("%s",add[i]);//gets address
    }
    printf("names and addresses are=\n");
    for(i=0;i<=n-1;i++)
    {
        printf("name =%s and adddress=%s\n",name[i],add[i]);//prints the data .
   
    }
getch();
     return 0;
}
------------------------------------

---------------------------------------------------------
using codeblocks
---------------------------------------
//WAP  to input any five names with address and display them.
#include <stdio.h>

int main()
{
    char name[100][100];//two dimensional declaration
    char add[100][100];//two dimensional declaration
    int i,n;
    printf("enter n\n");
    scanf("%d",&n);
    printf("enter names and addresses\n");
    for(i=0;i<=n-1;i++)
    {
        printf("name \n");
        scanf("%s",name[i]);//gets inputs for name
        printf("address=\n");
        scanf("%s",add[i]);//gets address
    }
    printf("names and addresses are=\n");
    for(i=0;i<=n-1;i++)
    {
        printf("name =%s and adddress=%s\n",name[i],add[i]);//prints the data .
   
    }
     return 0;
}


WAP to search a string in given list of strings

In codeblocks:
-----------------------------------------------------------------------------------
//program to search a string in given list of strings
#include <stdio.h>
#include<string.h>

int main()
{
    char string[100][100],st[100];
    int i,n,flag=0;
    printf("enter n\n");
    scanf("%d",&n);
 
    printf("enter strings\n");
 
    for(i=0;i<=n-1;i++)
    {
        scanf("%s",string[i]);
    }
    printf("enter string to be searched\n");
    scanf("%s",st);
    for(i=0;i<=n-1;i++)
    {
        if(strcmp(string[i],st)==0)
        {
            flag=1;break;
        }
    }
    if(flag==1)
    {
        printf("found and location=%d",i);
    }
    else
    {
    printf("not found");
    }
    return 0;
}
-------------------------------------------------------------------------------
In turboc++
----------------------------------------------------------------------------------------------------------
//program to search a string in given list of strings
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char string[100][100],st[100];
    int i,n,flag=0;
    printf("enter n\n");
    scanf("%d",&n);
    printf("enter strings\n");
 
    for(i=0;i<=n-1;i++)
    {
        scanf("%s",string[i]);
    }
    printf("enter string to be searched\n");
    scanf("%s",st);
    for(i=0;i<=n-1;i++)
    {
        if(strcmp(string[i],st)==0)
        {
            flag=1;break;
        }
    }
    if(flag==1)
    {
        printf("found and location=%d",i);
    }
    else
    {
    printf("not found");
    }
    getch();
    return 0;
}


WAP to count all characters after first white space

in turboc++
----------------------------------------------------------------------------------------
//WAP to count all characters after first white space.
#include <stdio.h>
#include<conio.h>
int main ()
{
  char string[100];
  int count=0,i,k;//variables declaration
  printf ("enter string\n");
  scanf ("%[^\n]s", string); //reads till new line is encountered or untill new line is encountered
  for ( i = 0; string[i] != '\0'; i++) //loop execution till the null character is reached.
    {
      if (string[i] == ' ') //condition testing
{
  break; //exits the loop and variable i's last value is taken
}
    }
    for (k=i+1; string[k] != '\0'; k++) //loop execution till the null character is reached from location i+1.
  {
      count++;                         //goes for increment
  }
  printf ("total characte after first space=%d",count);

  getch();
}









-------------------------------
in codeblocks
------------------------------------------------------------
//WAP to count all characters after first white space.
#include <stdio.h>

int main ()
{
  char string[100];
  int count=0,i,k;//variables declaration
  printf ("enter string\n");
  scanf ("%[^\n]s", string); //reads till new line is encountered or untill new line is encountered
  for ( i = 0; string[i] != '\0'; i++) //loop execution till the null character is reached.
    {
      if (string[i] == ' ') //condition testing
{
  break; //exits the loop and variable i's last value is taken
}
    }
    for (k=i+1; string[k] != '\0'; k++) //loop execution till the null character is reached from location i+1.
  {
      count++;                         //goes for increment
  }
  printf ("total characte after first space=%d",count);

  return 0;
}

WAP to print all characters before the first space.

using turboc++
---------------------------------------------------------
//WAP to count all characters after first white space.
#include <stdio.h>
#include<conio.h>
void main()
{
    char string[100];
    printf("enter string\n");
    scanf("%[^\n]s",string);//reads till new line is encountered or untill new line is encountered
    for(int i=0;string[i]!='\0';i++)//loop execution till the null character is reached.
    {
        if(string[i]==' ')//condition testing
        {
           break;             //exits the loop
        }
        else
        {
            printf("%c",string[i]);//prints the character

        }
    }

    getch();
}



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

using codeblocks
--------------------------------------------------

//WAP to count all characters after first white space.
#include <stdio.h>

int main()
{
    char string[100];
    printf("enter string\n");
    scanf("%[^\n]s",string);//reads till new line is encountered or untill new line is encountered
    for(int i=0;string[i]!='\0';i++)//loop execution till the null character is reached.
    {
        if(string[i]==' ')//condition testing
        {
           break;             //exits the loop
        }
        else
        {
            printf("%c",string[i]);//prints the character

        }
    }

    return 0;
}

WAP to initialize some characters and display them.

the code looks like
------------------------------------------------------
//program to initialize some characters and to print them
#include <stdio.h>
#include<conio.h>

void main()
{
    char name[10]={'r','m','a','n'};//initialization of characters
    int i;
    for(i=0;name[i]!='\0';i++)//loop execution untill null character
    {
        printf("%c",name[i]);//printing the value
    }
   

    getch();
}

---------------------------
second method
----------------------------------------------
//program to initialize some characters and to print them
#include <stdio.h>
#include<conio.h>

void main()
{
    char name[10]={'r','m','a','n'};//initialization of characters
 
        printf("%s",name);//printing the value
   
   

    getch();
}










-------------------------------
in codeblocks:-
-------------------------------
#include <stdio.h>

int main()
{
    char name[10]={'r','m','a','n'};
    int i;
    for(i=0;name[i]!='\0';i++)
    {
        printf("%c",name[i]);
    }
   

    return 0;
}