Jumat, 08 Juli 2011

Program to convert lowercase to uppercase

ALGORITHM:
STEP 1: Start the program.
STEP 2: Declare the variables.
STEP 3: Read the file name.
STEP 4: open the file to write the contents.
STEP 5: writing the file contents up to reach a particular condition.
STEP6: write the file contents as uppercase.
STEP7: open the file to read the contents.
STEP 8: Stop the program.
PROGRAM:

01#include<fstream.h>
02#include<stdio.h>
03#include<ctype.h>
04#include<string.h>
05#include<iostream.h>
06#include<conio.h>
07void main()
08{
09              char c,u;
10              char fname[10];
11              clrscr();
12              ofstream out;
13              cout<<"Enter File Name:";
14              cin>>fname;
15              out.open(fname);
16              cout<<"Enter the text(Enter # at end)\n";
17  //write contents to file
18              while((c=getchar())!='#')
19              {
20                            u=c-32;
21                            out<<u;
22              }
23              out.close();
24              ifstream in(fname);        //read the contents of file
25              cout<<"\n\n\t\tThe File contains\n\n";
26              while(in.eof()==0)
27              {
28                            in.get(c);
29                            cout<<c;
30              }
31              getch();
32 
33}

Output:
Enter File Name: two.txt
Enter contents to store in file (enter # at end)
oops programming
The File Contains
OOPS PROGRAMMING

Tidak ada komentar:

Posting Komentar