You are on page 1of 4

STRING PROGRAMS

1. WAP to find string length including spaces.


#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main!
"
clrscr!#
char string$%&'#
cout<<()n enter a string* (<<endl#
cin.getlinestring+%&!#
cout<<()n the length o, (<<string<<( is* (<<strlenstring!#
getch!#
-
Out.ut*


2. WAP to count the number of words in a string.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main!
"
clrscr!#
char string$/&'#
int count0%#
cout<<()n enter the string* (<<endl#
getsstring!#
,orint i01#i<strlenstring!#i22!
"
i,string$i'003 3!
"
count22#
-
-
cout<<(the 4ords in (<<string<<( are* (<<count#
getch!#
-
Out.ut*
3. WAP to count the number of lines in a paragraph.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main!
"
clrscr!#
char string$/&'#
int count01#
cout<<()n enter the string* (<<endl#
getsstring!#
,orint i01#i<strlenstring!#i22!
"
i,string$i'003.3!
"
count22#
-
-
cout<<(the lines in (<<string<<( are* (<<count#
getch!#
-
Out.ut*

You might also like