You are on page 1of 35

›  



  

|    

   

|  .

              !  "#       "    "  ""  "   $ !  "        "     |    .

    .

| % &" '% ()  %   "  "   &"  * "   !+     .-  "  .

     + |    .

    .

 .

-   /!       * "  0  " "      12 1    1  "1    . .  !       .-  |    .

    .

      12 1 1 "3    0  !+ |    .

    .

.

%4 "             ! "   * " ! !%   !"    "      ! 0#  +  .

.

 ! |    .

    .

 56-5 "     |    . "  %  .   " . +   m   "m   * "    #$%   &  |  1   !   4 "       !   ! .

    .

 ! %    "   "!!4 "           !" +  .

.

 !  .

m.

m  .

   "!   !% 7  "  + 8  "  !12 1  56-5 !             !    1  56-5    "   'm.

m 'm.

m .

   9  |    . .

    .

:4 "       ."  >  '(?1@    " +1)  '(?12  1) " 'A-() << ) ==" ) << <<" <<1B1) C |    . < "= .

    .

DD       .  <<3  +F) ==) DD <<3G   +F<<<< )DD" C |    ."  > E?A-)DD"  ' E() DD.

    .

þ ()* + .

'.

 ) +    .

  ""-. . // ›00 1 1-2  3.     .

        )  4  )41 . 1-.  .

   4    '   3.

    .

 5.

 ) .

5 1 .

†. ›6     -  .

5  .

 .

  +).

   (7.(þ+ 4 1 |    .

    .

DD       5.

 -. .

 //'        89: //  5 )  .  89:.

<<% (   "&  1- 89:.//4     .

.  - .

<<%=.

 "&<< <<  ! |    .

    .

clrscr(). in C Language while(sent[i]!='\0') { count++. int i=0. in C language cout<<"\n".get(sent. Max).count=0. i++. //puts(sent). cout<<"enter sentence \n".h> //#include<stdio. WAP to count the number of characters in a string #include<iostream. getch(). cin. }cout<<"\n no of characters = "<<count. cout<<sent.h> #include<conio. char sent[Max]. //gets(sent).h> //for gets and puts //Count the number of characters in a string void main() { const int Max = 100.} |    .

    .

//gets(sent).} |    . WAP to count the number of words in a sentence #include<iostream. cout<<sent.h> #include<conio. cin.}cout<<"\n no. getch(). int i=0. in C Language cout<<"\n". clrscr().count=1. i++. cout<<"enter sentence \n".get(sent. while(sent[i]!='\0') { if (sent[i]==' '&& sent[i+1]!=' ') count++. char sent[MAX]. of words = "<<count. MAX).h> //#include<stdio.h> //Count the number of words in a sentence void main() {const int MAX = 100.

    .

      |    .þ 8  46  !  " ++    &" % &   " &           .  "   ! H6I     !"   "     ! .

    .

//       5.

 .  -.

 89: //'        89: //  5 )  .

 //   ? . <<% (   " &  1- 89:>?@.

<<%=.

 " &<< <<  ! 7.

.

 4    .

 4  .

  .  1 .

 .

 .

4    .

      -.

  .

'  3.

 .1 þ).

   4 ( 4  >?@  1 |    .

    .

     ).

) )   .

.

   .

  . .   -  .

.

      ) .

     1      5 )   5   5 .

   .

  )   .   1.

 1  ›.

) .4   A .

       .

    .

    )  1. .

.

 4.

.

  1 |    .

    .

//.

4     .

.

.

4 B  < .

1 C B  <  1 C 5.

    #%D ›4 ›4 E.  -.

  4 .

& .

 // 3.  89:.

 )    89: //4   .

- <  - #. //.00.

4      # //.

 #.

  > @ // 7F66  .

<< <<  // 4  ! |    .

    .

'0(?H6-I) .     "    " .  "  " ! 2! .'0(?J'0()   .            K     I    K  !  .

I   I    " !   ! !  <<0#    ! .      H6-I |    .

    .

 ›.

4   ( A 4-   .

 .

.   !#"#  "          "  .     F| L2.

F )  ! 3| L2.

 |    . J  %  J      .  "   " J . )  !   . .   .F .  .

    .

' E()DD " . <<."  > J'(?3     6F)  E?A-)DD% . C |    .  . J )DDJ.DD       .<< )DD.

    .

 9 .

  2  I "  "   ! #+ DD ."  >|G?M)DD"   E?J-)DD"""%   DD '|G(' E(?>3F 3 F 3  F  3K  F 3 F 3*F 3FC) 0?-)0<|G)0NN  DD .  <<'0(<< ) C |    .

    .

O   .

´there´). If the value is negative.string2).. string1 is alphabetically above string2. It takes the form strcmp(string1. |    .g. e. If they are not. which is alphabetically above. strcmp(³their´. ³i´ minus ³r´ in ASCII code is ±9.  uhe strcmp function compares two strings identified by the arguments and has a value 0 if they are equal. uhe value of the mismatch is rarely important. will return a value of ±9 which is the numeric difference between ASCII ³i´ and ASCII ³r´. string1 and string2 may be string variables or string constants. if not. it has the numeric difference between the first non matching characters in the strings. Our major concern is to determine whether the strings are equal. uhat is.

    .

O    .

It takes the following form: strcat(string1. It does so by removing the null character at the end of string1 and placing string2 from there. string1 and string2 are character arrays. string2 is appended to a string1. uhe string at string2 remains unchanged.string2).   uhe strcat function joins two strings together. |    . When the function strcat is executed.

    .

s2[50]. WAP to concatenate two strings #include<iostream.h> #include<stdio.h> #include<string. strcat(s1.h> #include<conio. } |    . getch(). cout<<"\nConcatenated string is".s2).h> void main() { char s1[40]. cout<<"\nEnter the second string". cout<<³concatenated=³<<s1. gets(s1). cout<<"\nEnter the first string". gets(s2).

    .

2-D character array consists of strings as its individual elements. Declaration :- char a[10][10]. uwo Dimensional Character Arrays uhese Are arrays of arrays. |    . Initialization:- char a[10][20]={³aaa´. ³bbb´. ³ccc´ }.

    .

i<no.i<no. } |    . cout<<"\nEnter the array of strings:". int no. cin>>no. } getch().void main() { char string[30][30].i++) { puts(string[i]).i++) { gets(string[i]).i. for(i=0. } for(i=0. cout<<"\nEnter the number of strings:".

    .

} |    . cout<<"\nEnter the array of strings:". int no. cin>>no.temp[30].j. for(i=0.i.i++) { gets(string[i]). WAP to sort n names in alphabetical order void main() { char string[30][30]. cout<<"\nEnter the number of strings:".i<no.

    .

} getch(). } |    .j++) { if(strcmp(string[i].i++) { puts(string[i]).for(i=0.string[j])>0) { strcpy(temp. strcpy(string[j].temp).string[i]).i++) { for(j=i+1.i<no-1.string[j]). } } } cout<<"\nuhe sorted array is:". for(i=0.i<no.j<no. strcpy(string[i].

    .

else cout<<"\nString is not a Palindrome".n.str[i]!='\0'. for(i=0.i++). n=i.j. |    . break. gets(str). WAP to check whether a string is Palindrome or not void main() { char str[30]. int i.i++) { if(str[i]!=str[n-i-1]) { flag=0. cout<<"\nEnter the string:".flag=1. for(i=0.i<n/2. } } if(flag==1) cout<<"\nString is a Palindrome".

    getch().} .

int i.i++) n++. } cout<<"\nuhe reversed string is:".str[i]!='\0'.i++) { temp=str[i].n=0. char temp. str[i]=str[n-i-1]. cout<<"\nEnter the string:". for(i=0.i<n/2. } |    . gets(str). getch(). WAP to reverse a string void main() { char str[70]. for(i=0. str[n-i-1]=temp. puts(str).

    .

K@  " " ." > )  ) <<161) ?78)<?J.)?NJ > =O-PP<OM  ) <<<<141<< <<11) C <<161) C |    ..

    .

n=0. int i.i++) n++. WAP to change all lower case letters into uppercase in a sentence void main() { char string[30].i<n.string[i]!='\0'.i++) { if(string[i]>=97 && string[i]<=122) string[i]=string[i]-32. getch(). cout<<"\nEnter the string". } |    . } puts(string). for(i=0. for(i=0. gets(string).

    .

 <= DD #.. < "= . <= .  " 'J-( 'J-( ?- )  0 # ) <<1  61) ==" ) ? " ) <<1  61) ==) "?  ) 0?- ?-) ! '0(B?56-5 > ?-) |    .

    .

'0(B?" '(  >NN) )C   ?) N" <? >#?)#<N")#NN >'0(??" '#( >NN)0NN) )C  > ?#) '0(B?H6-I 0?-)  #) C C C C "?? <<1      " 63<<3?3<<NJ)   <<19  61)   )C |    .

    .