C++ program that would create display and count words,vowel and digits present in a file

C++ program that would create display and count words,vowel and digits present in a file
So are u searching for a c++ based program that would work on the properties of files,you have visited the right place. This is a program that works on the switch case property which handles a set of data in the file simultaneously. Through this program we shall learn how to use the different functions of a file like opening closing or updating it. A very helpfull program to learn about a file in dept. This is a c++ based program that would help in creating a file in the first switch option means it will give you an option of writing text documents in the file. The second switch option is to count the number of vowels or words or digits present in the text presently written in a pre created file. The vowels, words or digits are encountered with the help of "if" case once they are encoutered these are stored in a seperate variable and displayed seperately. The third switch option is to display contents present in the file. This was all about the program so without wasting much time lets start with the program. The disscused program is as follows:
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<process.h>
void main()
{
clrscr();
int n,j;
fstream ofile,afile;
char str[100];
char ch,ch1;

do
{
cout<<"\n\t1.Create Text\n\t2.Count vowels/words/digits\n\t3.Show Text\n\t4.Exit";
cin>>ch;
switch(ch)
{
    case '1' :
ofile.open("smp.txt",ios::out);
cout<<"\n Enter The Text ";
gets(str);
ofile<<str;
ofile.close();
break;
    case '2' :
char tmp1;
int v=0,d=0,w=0;
afile.open("smp.txt",ios::in);
while(!afile.eof())
{
afile.get(tmp1);

if(tmp1=='a'||tmp1=='e'||tmp1=='i'||tmp1=='o'||tmp1=='u')
v++;
if(isdigit(tmp1))
d++;
if(tmp1==' '||tmp1=='.')
w++;

}
afile.close();
cout<<"\n No of Vowels: "<<v;
cout<<"\n No of digits: "<<d+1;
cout<<"\n No of words: "<<w;
break;
    case '3' :
char tmp2;
afile.open("smp.txt",ios::in);
ofile.open("spl.txt",ios::out);
while(!afile.eof())
{
afile.get(tmp2);
if(tmp2==' ')
{
ofile<<'#';
}
else
{
ofile<<tmp2;
}
}
afile.close();
ofile.close();

cout<<"\nFormatted text:\t";
afile.open("spl.txt",ios::in);
while(afile)
{
afile.get(ch);
cout<<ch;
}
afile.close();
break;
    case '4' : exit(0);
}
cout<<"\n\t DO U want to continue ";
cin>>ch1;
  }while(ch1=='Y'||ch1=='y');
getch();
}

A program to give input and output in a file using switch cases

A program to give input and output in a file using switch cases
This is a c++ program created through switch case in which the user gets a switching option of creating a file and displaying the elements of the file. This program uses the funtions to open and cloase a file. Through this program a student can clarify his\her difficulties in defining a file. In this program new header files too are used such as process.h, fstream.h and few more. File is actually a very essential part of c++ so this can be clarified by this simple and basic program. A student can enhance his\her knowledge in file concept. So friends without wasting much of our time lets start with the program the program is as follows:

#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
clrscr();
int n,j;
fstream ofile,afile;
char str[100];
char ch,ch1;

do
{
cout<<"\n\t1.Enter Text\n\t2.Show Text\n\t3.Exit";
cin>>ch;
switch(ch)
{
    case '1' :
ofile.open("smp.txt",ios::out);
cout<<"\nEnter The Text ";
gets(str);
ofile<<str;
ofile.close();
char tmp[20];
afile.open("smp.txt",ios::in);
ofile.open("vwl.txt",ios::out);
while(!afile.eof())
{
afile.getline(tmp,20,' ');
if(tmp[0]=='a'||tmp[0]=='e'||tmp[0]=='i'||tmp[0]=='o'||tmp[0]=='u')
{
ofile<<tmp;
ofile<<' ';
}
}
afile.close();
ofile.close();

break;
    case '2' : cout<<"\nFormatted text:\t";
afile.open("vwl.txt",ios::in);
while(afile)
{
afile.get(ch);
cout<<ch;
}
afile.close();
break;
    case '3' : exit(0);
}
cout<<"\n\t DO U want to continue ";
cin>>ch1;
  }while(ch1=='Y'||ch1=='y');
getch();
}

Program to generate report card of a student using functions like setw and gotoxy

Program to generate report card of a student using functions like setw and gotoxy
This is a c++ program that will take input of employees datails such as name, number and salary. Using switch case this will generate a report card of the student in tabular form. In this program we will learn about a new function "setw()" due to this a new header file is also introduced that is "process.h". this could teach one a good concept of how to create a report card of a student with proper arrangment. Without disscusing much lets work on the program, the program comes as follows:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<iomanip.h>
class employee
{
int eno;
char name[30];
float salary;
public :
void input()
{
cout << "Enter Employee Number ";
cin >>eno;
cout << "Enter name ";
gets(name);
cout << "Enter salary ";
cin >>salary;
}
void show()
{
cout << eno << setw(20)<<name<<setw(20)<<salary<<endl;
}
float rt_sal()
{
return salary;
}
}emp[10];
main()
{
int n,ch,i,j;
char choice;
do
{
clrscr();
cout << "1. For enter "<<endl;
cout << "2. For tabular report"<<endl;
cout << "3. For exit";
cin >> ch;
switch(ch)
{
case 1: cout << "Enter how many employees ";
cin >>n;
for(i=0;i<n;i++)
{
emp[i].input();
}

break;
case 2:
employee temp;
for (i=0;i<n;i++)
{
for(j=i;j<n-1;j++)
{
if (emp[j].rt_sal()>emp[j+1].rt_sal())
{
temp = emp[j];
emp[j]=emp[j+1];
emp[j+1]=temp;
}
}
}
gotoxy(6,6);
cout <<"Employee Number ";
gotoxy(26,6);
cout <<"Name";
gotoxy(46,6);
cout <<"Salary"<<endl;
int r = 8;
for(i=0;i<n;i++)
{
emp[i].show();
r++;
}

break;
case 3: exit(0);

}
cout << "\n Do U want to continue";
cin>>choice;
}while(choice == 'Y' ||choice =='y');

}

A program to clarify the use of files how to open how to close

A program to clarify the use of files how to open how to close
This is a c++ program made using files to generate a report of enggineering student. In this program it will take input of students full info like name, roll and marks.this program includes the concept of opening and cloasing of file. This program also includes a few extra header files and also the concept of switch case too. The program is as follows:
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<ctype.h>
class student
{
char name[30];
int rollno;
int marks;
public:
void input()
{
cout<<"\nEnter Name: ";
gets(name);
cout<<"Enter Rollno.: ";
cin>>rollno;
cout<<"enter marks";
cin>>marks;
}
void display()
{
cout<<"\n"<<name<<"\t"<<rollno<<"\t"<<marks<<"\t";
if(marks>=96)
cout<<"computer sc.";
else if(marks>=91&&marks<=95)
cout<<"Electronics";
else if(marks>=86&&marks<=90)
cout<<"Mechanical";
else if(marks>=81&&marks<=85)
cout<<"Electrical";
else if(marks>=76&&marks<=80)
cout<<"Chemical";
else if(marks>=71&&marks<=75)
cout<<"Civil";
else
cout<<"none";

}

};
void main()
{
clrscr();
student s;
int n,i,j;
fstream ofile,afile;

char ch,ch1;

do
{
cout<<"\n\t1.Add records\n\t2.Show Records\n\t3.Exit\n";
cout<<"Enter your choice: ";
cin>>ch;
switch(ch)
{
    case '1' :
ofile.open("st.dat",ios::app|ios::binary);
cout<<"\nEnter no. of records to be Entered: ";
cin>>n;
for(i=0;i<n;i++)
{
s.input();
ofile.write((char*)&s,sizeof(student));
}
ofile.close();
break;
    case '2' : cout<<"\nName\tRollno\tMarks\tStream";
afile.open("st.dat",ios::in);
while(afile)
{
afile.read((char *)&s,sizeof(student));
if (!afile)
break;
s.display();
}
afile.close();
break;
    case '3' : exit(0);
}
cout<<"\n\t DO U want to continue <Y/N>: ";
cin>>ch1;
  }while(tolower(ch1)!='n');
getch();

}