Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Object Oriented ProgrammingRSS Feeds

Program that list of letters should be an alphabetical list of upper case letters followed by an alphabetical list of lower case letters

Posted By: Easy Tutor     Category: C++ Programming     Views: 5809

Write a program that list of letters should be an alphabetical list of upper case letters followed by an alphabetical list of lower case letters.

#include <stdio.h>

main()
{
int i;
char *suffix[]= { "st", "nd", "rd" };
char *item[]= { "Unix" , "cat", "sed", "awk", "grep", "ed", "vi"};

printf("In the beginning, there was nothing.\n");
for (i= 0; i < 7; i++)
printf("And on the %d%s day, God created %s. And it was good.\n",
i + 1, (i < 3) ? suffix[i] : "th", item[i]);
}
But then God saw that vi led people into temptation. Instead of choosing the righteous ways of make, dbx, and RCS, people used long command lines, printf(), and tape backups.
So God decreed, ``I see that Engineers have thus defiled my vi. And so, I shall create emacs, an editor more powerful than words. Further, for each instantiation vi hitherto, the Engineer responsible shalt perform Penance. And lo, the Penance wilt be painful; there will be much wailing and gnushingof teeth. The Engineer will read many lines of text. For each line of text, the Engineer must tell me which letters occur the most frequently.''
``I charge you all with My Golden Rule: 'Friends shalt not let friends use vi'.''
Each line of output should contain a list of letters that all occured with the highest frequency in the corresponding input line, followed by the frequency.
The list of letters should be an alphabetical list of upper case letters followed by an alphabetical list of lower case letters.


When riding your bicycle backwards down a one-way street, if the
wheel falls of a canoe, how many ball bearings does it take to fill
up a water buffalo?
Hello Howard.

Code for Program that list of letters should be an alphabetical list of upper case letters followed by an alphabetical list of lower case letters in C++ Programming

 # include <iostream.h>
 # include <fstream.h>
 # include <string.h>
 # include <stdlib.h>
 # include <ctype.h>
 # include <conio.h>

 int main( )
    {
       clrscr( );

       fstream File("CP-14.txt",ios::in|ios::nocreate);

       if(!File)
      {
         cout<<"Unable to open the input file."<<endl;
         cout<<"Press any key to exit."<<endl;

         getch( );
         exit(EXIT_FAILURE);
      }

       char Data[100]={NULL};

       do
      {
         strset(Data,NULL);

         File.getline(Data,80,'\n');

         if(strcmp(Data,NULL)==0)
        break;

         int frequency[52]={0};

         int length=strlen(Data);

         for(int i=0;i<length;i++)
        {
           if(isalpha(Data[i]))
              {
              if(isupper(Data[i]))
                 frequency[(int(Data[i])-65)]++;

              elseif(islower(Data[i]))
                 frequency[(int(Data[i])-97+26)]++;
              }
        }

         int highest_frequency=0;

         for(int j=0;j<52;j++)
        {
           if(frequency[j]>highest_frequency)
              highest_frequency=frequency[j];
        }

         for(int k=0;k<52;k++)
        {
           if(frequency[k]==highest_frequency)
              {
             if(k>=0 && k<=25)
                cout<<char((k+65));

             elseif(k>=26 && k<=51)
                cout<<char((k+97-26));
              }
        }

         cout<<" "<<highest_frequency<<endl;
      }
       while(1);

       File.close( );

       getch( );
       return 0;
    }
  
Share: 



Easy Tutor
Easy Tutor author of Program that list of letters should be an alphabetical list of upper case letters followed by an alphabetical list of lower case letters is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!