Showing posts with label Data File Handling. Show all posts
Showing posts with label Data File Handling. Show all posts

C++ Program To Count Number Of Alphabets In A File

How to write C++ Program To Count Number Of Alphabets In A File in C++ programming ?


C++ Program To Count Number Of Alphabets In A File Character Count from a File, File handling program to count number of characters in a file, Program to count number of characters in specified string in C++ C Program to count number of characters in the file Write a c program to count the number of character C Program to count no. of characters, lines, spaces & tabs, C Program to count number of characters in the file. In this program you can learn c file operations.
C++ Program To Count Number Of Alphabets In A File


Solution:
//Program to count number of alphabets in a file.
#include<fstream.h>
#include<conio.h>
#include<ctype.h>
void main()
{
clrscr();
int count=0;
char a;

ofstream ofile("file.txt");
ofile<<"abcde34fghi43jkl34m234nop2343252qrst34uvwxyz";
ofile.close();

ifstream ifile("file.txt");
while(!ifile.eof())
{
ifile.get(a);
if(isalpha(a))
count++;
}
cout<<count;
getch();
}

This C++ Program executes To Count Number Of Alphabets In A File in C++ programming.

C++ File Handling Binary files - class EMPLOYEE

Assuming the class EMPLOYEE given below, write functions in C++ to perform following:

(i) Write the objects of EMPLOYEE to a binary file.
(ii) Read the objects of EMPLOYEE from binary file and display them on screen.

Assuming the class EMPLOYEE given below, write functions in C++ to perform following:  (i) Write the objects of EMPLOYEE to a binary file. (ii) Read the objects of EMPLOYEE from binary file and display them on screen.
C++ File Handling Binary files - class EMPLOYEE 


Solution:
class EMPLOYEE
{
            int ENO;
            char ENAME[10];
            public :
            void GETIT()
            {
                        cin >> ENO;
                        gets (ENAME);
            }
            void SHOWIT()
           {
                        cout <<ENO << ENAME <<endl;
            }
};

This C++ Program executes the objects of EMPLOYEE to a binary file and Read the objects of EMPLOYEE from binary file and display them on screen.

C++ Program To Write Numbers 1 to 100 in a data file

How to write a C++ Program to write numbers one to hundred in a data file notes.txt in C++ Programming.


C++ Program to write numbers 1 to 100 in a data file notes.txt in C++ Programmin.
C++ Program to write numbers one to hundred in a data file notes.txt in C++ Programmin.


Solution:
//Program to write numbers one to hundred in a data file notes.txt
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();

ofstream ofile("notes.txt");
for(int i=1;i<=100;i++)
ofile<<i<<" ";
ofile.close();

char a;
ifstream ifile("notes.txt");
while(!ifile.eof())
{
ifile.get(a);
cout<<a;
}
getch();
}

This C++ Program to write numbers one to hundred in a data file notes.txt in C++ Programming.

C++ Initializes A String Variable And Outputs String To Disk File

How to write a C++ Program which initializes a string variable and outputs the string to the disk file in C++ programming.

C++ Program which initializes a string variable and outputs the string to the disk file in C++ programming.
C++ Program which initializes a string variable and outputs the string to the disk file in C++ programming.


Solution:
//Program which initializes a string variable and outputs the string to the disk file.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();
char a[]="Program which initializes a string variable and outputs the string to the disk file.";

ofstream ofile("disk.txt");
ofile<<a;
ofile.close();

char b;
ifstream ifile("disk.txt");
while(!ifile.eof())
{
ifile.get(b);
cout<<b;
}
getch();
}

This C++ Program which initializes a string variable and outputs the string to the disk file in C++ programming.

Read Content From a Text File then Count and Display the Number of Alphabets

How to write a C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it in C++ Programming.


C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it
C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it 


Soulution:
//Program to read content from a text file out.txt, count and display the number of alphabets present in it.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();

char a;
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile.get(a);
if((a>=65 && a<=90)||(a>=97&&a<=122))
{
count++;
cout<<a;
}
}
cout<<endl<<"Number of aplhabets in the file out.txt: "<<count;
getch();
}

This C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it in C++ Programming.

C++ Program to count number of blanks present in a text file

How to write a C++ Program to count number of blanks present in a text file in C++ Programming.

C++ Program to count number of blanks present in a text file
C++ Program to count number of blanks present in a text file


Solution:
//Program to count number of blanks present in a text file.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();

char a;
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile.get(a);
if(a==32)
count++;
}
cout<<endl<<"Number of blanks in the file out.txt: "<<count;
getch();
}

This C++ Program to count number of blanks present in a text file.

C++ Program to count number of words in a text file

How to write Program to count number of words in a text file in C++ Programming.


C++ Program to count number of words in a text file
C++ Program to count number of words in a text file


Solution:
//Program to count number of words in a text file.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();

char a[80];
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile>>a;
count++;
}
cout<<endl<<"Number of words in the file out.txt: "<<count;
getch();
}

.This C++ Program to count number of words in a text file

C++ Program to Counting Words "the" in a Text File

How to write Program to count number of times the word 'the' as an independant word in a text file in C++ Programming.

Program to count number of times the word 'the' as an independant word in a text file in C++ Programming.
C++ Program to Counting Words "the" in a Text File

Solution:
//Program to count number of times the word 'the' as an independant word in a text file.
//out.txt:-"The C++ is a the general purpose the programmingthe language."
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
void main()
{
clrscr();

char a[80];
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile>>a;
if((strcmp(a,"the")==0)||(strcmp(a,"The")==0));
count++;
}
cout<<endl<<"Number of 'the' in the file out.txt: "<<count;
getch();
}

This C++ Program to count number of times the word 'the' as an independant word in a text file.