C Programming Tutorial

Advertisements

Write a program to count total worlds starting with upper letter or upper case in C++



       #include<fstream.h>
       #include<conio.h>

       void main()
       {
              fstream f;
              char wrd[20];
              int count=0;
              clrscr();

              f.open("file1.txt",ios::in);
                            
              while(!f.eof())
              {
                     f>>wrd;
                     
                     if( (wrd[0]>='A') || (wrd[0]<='Z') )
                     count++;
              }
              
              cout<<"\nTotal words starting with upper case : "<< count;

              f.close();

              getch();
    }




Advertisement