-->

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;
}


WAP to print a string.

code is
------------------------------------------------

>>> name="Nepal"
>>> print name
Nepal
>>> print("name=%s"%name)
name=Nepal
>>>


-----------------------------
output is
----------------------------------------
Nepal
name=Nepal as print in above code.
--------------------------------
screen shot is
-------------------

wap to print hello world in python

the code is:
------------------------------------------------------------------------------------
print("hello world");

------------------------------
output is:-
--------------
hello world



screenshot is

Python basic programs

Click following to understand the program
------------------------------------------------------------
WAP to understand comment with hello python text in python.

                                                                                                                       
                                                                                                       
                                                                                                                         solution

                                                                                                                         solution





.WAp to print hello world in Python.

                                                                                                                            solution

.WAP to print a string.

                                                                                                                             solution


WAP to find sum of two numbers 3 and 4.

                                                                                                                             solution