Vous êtes sur la page 1sur 4

#include <stdio.

h>

#include <fstream.h>

#include <conio.h>

#include <process.h>

#include <stdlib.h>

#include <string.h>

#include <ctype.h>

void main()

char sent[80],cho='y';

int n,c,i;

int a=0,b=0,A=0,B=0,sc=0,w=0,dig=0,count=0;

ofstream ofile("text1.txt");

if(!ofile)

cout<<"Problems";

exit(0);

ifstream ifile("text1.txt");

if(!ifile)

cout<<"File open error";

exit(0);

do

{ clrscr();

gotoxy(10,5);

cout<<"MENU";

gotoxy(10,6);

cout<<"1. Input";
gotoxy(10,7);

cout<<"2. Display";

gotoxy(10,8);

cout<<"3. End";

gotoxy(10,10);

cout<<"Enter your choice sir: ";

cin>>c;

switch (c)

case 1:

clrscr();

cout<<"Number of sentences";

cin>>n;

clrscr();

for( i=1;i<=n;i++)

cout<<"Enter sentence. Terminate with '.'";

gets(sent);

ofile.write(sent,strlen(sent));

ofile.close();

cout<<"Do you wish to conti?";

cin>>cho;

break;

case 2:

char ch;

while(ifile)

ifile.get(ch);

if(isupper(ch)!=0)

{
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')

A++;

else

B++;

else if(islower(ch)!=0)

if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')

a++;

else

b++;

else if(isdigit(ch)!=0)

dig++;

else if(ch==' ')

w++;

else if(ch=='.')

w++;

else

sc++;

ifile.close();

clrscr();

cout<<"Capital vowels: "<<A<<"\n";

cout<<"Capital consts: "<<B<<"\n";

cout<<"Small vowels: "<<a<<"\n";

cout<<"Small consts: "<<b<<"\n";

cout<<"Numbers: "<<dig<<"\n";
cout<<"Words: "<<w<<"\n";

cout<<"Special charaters: "<<sc-1<<"\n";

cout<<"Do you wish to conti?";

cin>>cho;

break;

case 3:

clrscr();

cout<<"THANK YOU";

exit(0);

}while(cho=='y');

clrscr();

cout<<"THANK YOU";

Vous aimerez peut-être aussi