SlideShare una empresa de Scribd logo
1 de 4
/* WAP to create a text file(.txt) and display number of words, alphabets, vowels and consonants and number
of lowercase and uppercase letters using the concept of DATA FILE HANDLING. */
#include<fstream.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
void main()
{
clrscr();
char a[80];
int words=0, upper_letters=0, lower_letters=0, alpha=0, vowels=0,consonants=0;
ofstream string("str.txt");
cout<<"nnEnter the string : ";
cin.getline(a,79);
string<<"The string is : "<<a<<"nn";
for(int i=0; i<strlen(a); i++)
{
if(a[i]==' ')
while(a[i]==' ')
{
i++;
}
if(isalnum(a[i]))
{
while(a[i]!=' ')
{
i++;
}
words++;
}
}
string<<"nnThe number of words in string are : "<<words;
string<<"nnnAlphabets in string are : nn";
for(i=0; i<strlen(a); i++)
{
if(isalpha(a[i]))
{
alpha++;
string<<a[i]<<" ";
}
}
string<<"nnTotal number of alphabets in string => "<<alpha;
string<<"nnnUppercase letters in string are : nn";
for(i=0; i<strlen(a); i++)
{
if(isupper(a[i]))
{
upper_letters++;
string<<a[i]<<" ";
}
}
string<<"nnTotal number of uppercase letters in string => "<<upper_letters;
string<<"nnnLowercase letters in string are : nn";
for(i=0; i<strlen(a); i++)
{
if(islower(a[i]))
{
lower_letters++;
string<<a[i]<<" ";
}
}
string<<"nnTotal number of Lowercase letters in string => "<<lower_letters;
string<<"nnnVowels in string are : nn";
for(i=0; i<strlen(a); i++)
{
if(isalpha(a[i]))
{
if(a[i]=='a'||a[i]=='A'||a[i]=='e'||a[i]=='E'||a[i]=='i'||a[i]=='I'||a[i]=='o'||a[i]=='O'||a[i]=='u'||a[i]=='U')
{
vowels++;
string<<a[i]<<" ";
}
}
}
string<<"nnTotal number of vowels in string => "<<vowels;
string<<"nnnConsonants in string are : nn";
for(i=0; i<strlen(a); i++)
{
if(isalpha(a[i]))
{
if(a[i]!='a'&&a[i]!='A'&&(a[i]!='e'&&a[i]!='E'&&a[i]!='i'&&a[i]!='I'&&(a[i]!='o'&&a[i]!='O')&&a[i]!='u'&&a[i]!='U')
{
consonants++;
string<<a[i]<<" ";
}
}
}
string<<"nnTotal number of vowels in string => "<<consonants;
getch();
}
Output :
Enter the string: Rahul Verma
Output of created textfile:
The string is: Rahul Verma
The numberof wordsinstringare : 2
Alphabetsinstringare :
R a h u l V e r m a
Total numberof alphabetsinstring=> 10
Uppercase lettersinstringare :
R V
Total numberof uppercase lettersinstring=>2
Lowercase lettersinstringare :
a h u l e r m a
Total numberof Lowercase lettersinstring=>8
Vowels instringare :
a u e a
Total numberof vowelsinstring=> 4
Consonantsinstringare :
R h l V r m
Total numberof vowelsinstring=> 6

Más contenido relacionado

La actualidad más candente

Template Haskell Tutorial
Template Haskell TutorialTemplate Haskell Tutorial
Template Haskell Tutorial
kizzx2
 
Cloud flare jgc bigo meetup rolling hashes
Cloud flare jgc   bigo meetup rolling hashesCloud flare jgc   bigo meetup rolling hashes
Cloud flare jgc bigo meetup rolling hashes
Cloudflare
 

La actualidad más candente (8)

Recognize Godzilla
Recognize GodzillaRecognize Godzilla
Recognize Godzilla
 
Template Haskell Tutorial
Template Haskell TutorialTemplate Haskell Tutorial
Template Haskell Tutorial
 
5.managing hdfs
5.managing hdfs5.managing hdfs
5.managing hdfs
 
Cloud flare jgc bigo meetup rolling hashes
Cloud flare jgc   bigo meetup rolling hashesCloud flare jgc   bigo meetup rolling hashes
Cloud flare jgc bigo meetup rolling hashes
 
Patrick zheng week4_demo3
Patrick zheng week4_demo3Patrick zheng week4_demo3
Patrick zheng week4_demo3
 
MongoDB World 2019: Exploring your MongoDB Data with Pirates (R) and Snakes (...
MongoDB World 2019: Exploring your MongoDB Data with Pirates (R) and Snakes (...MongoDB World 2019: Exploring your MongoDB Data with Pirates (R) and Snakes (...
MongoDB World 2019: Exploring your MongoDB Data with Pirates (R) and Snakes (...
 
Haskell
HaskellHaskell
Haskell
 
Data warehouse or conventional database: Which is right for you?
Data warehouse or conventional database: Which is right for you?Data warehouse or conventional database: Which is right for you?
Data warehouse or conventional database: Which is right for you?
 

Similar a Wap to create a text file and display number of words

Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! 
aleks-f
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
ezonesolutions
 

Similar a Wap to create a text file and display number of words (20)

Files
FilesFiles
Files
 
String
StringString
String
 
2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings 2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings
 
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptxINDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptx
 
C Language Lecture 13
C Language Lecture 13C Language Lecture 13
C Language Lecture 13
 
Program to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical orderProgram to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical order
 
SPL 13 | Character Array(String) in C
SPL 13 | Character Array(String) in CSPL 13 | Character Array(String) in C
SPL 13 | Character Array(String) in C
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
 
streams and files
 streams and files streams and files
streams and files
 
Lecture 1 string functions
Lecture 1  string functionsLecture 1  string functions
Lecture 1 string functions
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! 
 
Beyond javascript using the features of tomorrow
Beyond javascript   using the features of tomorrowBeyond javascript   using the features of tomorrow
Beyond javascript using the features of tomorrow
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
 
Arrays & Strings.pptx
Arrays & Strings.pptxArrays & Strings.pptx
Arrays & Strings.pptx
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
Module-2_Strings concepts in c programming
Module-2_Strings concepts in c programmingModule-2_Strings concepts in c programming
Module-2_Strings concepts in c programming
 
U4.ppt
U4.pptU4.ppt
U4.ppt
 
STL
STLSTL
STL
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
 

Último

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Último (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 

Wap to create a text file and display number of words

  • 1. /* WAP to create a text file(.txt) and display number of words, alphabets, vowels and consonants and number of lowercase and uppercase letters using the concept of DATA FILE HANDLING. */ #include<fstream.h> #include<string.h> #include<ctype.h> #include<conio.h> void main() { clrscr(); char a[80]; int words=0, upper_letters=0, lower_letters=0, alpha=0, vowels=0,consonants=0; ofstream string("str.txt"); cout<<"nnEnter the string : "; cin.getline(a,79); string<<"The string is : "<<a<<"nn"; for(int i=0; i<strlen(a); i++) { if(a[i]==' ') while(a[i]==' ') { i++; } if(isalnum(a[i])) { while(a[i]!=' ') { i++; } words++; } } string<<"nnThe number of words in string are : "<<words; string<<"nnnAlphabets in string are : nn"; for(i=0; i<strlen(a); i++) { if(isalpha(a[i])) { alpha++; string<<a[i]<<" "; }
  • 2. } string<<"nnTotal number of alphabets in string => "<<alpha; string<<"nnnUppercase letters in string are : nn"; for(i=0; i<strlen(a); i++) { if(isupper(a[i])) { upper_letters++; string<<a[i]<<" "; } } string<<"nnTotal number of uppercase letters in string => "<<upper_letters; string<<"nnnLowercase letters in string are : nn"; for(i=0; i<strlen(a); i++) { if(islower(a[i])) { lower_letters++; string<<a[i]<<" "; } } string<<"nnTotal number of Lowercase letters in string => "<<lower_letters; string<<"nnnVowels in string are : nn"; for(i=0; i<strlen(a); i++) { if(isalpha(a[i])) { if(a[i]=='a'||a[i]=='A'||a[i]=='e'||a[i]=='E'||a[i]=='i'||a[i]=='I'||a[i]=='o'||a[i]=='O'||a[i]=='u'||a[i]=='U') { vowels++; string<<a[i]<<" "; } } } string<<"nnTotal number of vowels in string => "<<vowels; string<<"nnnConsonants in string are : nn"; for(i=0; i<strlen(a); i++) { if(isalpha(a[i])) { if(a[i]!='a'&&a[i]!='A'&&(a[i]!='e'&&a[i]!='E'&&a[i]!='i'&&a[i]!='I'&&(a[i]!='o'&&a[i]!='O')&&a[i]!='u'&&a[i]!='U') {
  • 3. consonants++; string<<a[i]<<" "; } } } string<<"nnTotal number of vowels in string => "<<consonants; getch(); }
  • 4. Output : Enter the string: Rahul Verma Output of created textfile: The string is: Rahul Verma The numberof wordsinstringare : 2 Alphabetsinstringare : R a h u l V e r m a Total numberof alphabetsinstring=> 10 Uppercase lettersinstringare : R V Total numberof uppercase lettersinstring=>2 Lowercase lettersinstringare : a h u l e r m a Total numberof Lowercase lettersinstring=>8 Vowels instringare : a u e a Total numberof vowelsinstring=> 4 Consonantsinstringare : R h l V r m Total numberof vowelsinstring=> 6