Error(s) found: '1'

  • Unable to perform the query 'UPDATE cpp_code SET clickthru=clickthru+1 WHERE fid=1'. Table 'cpp_code' is read only.

  • C++ MADE EASY
    Code About Us Tutorial




       
     

    Home > myCode > Convert to Upper

    November 26, 2009 6:03 pm

       

    Convert to Upper


    Posted on: 2001-09-07 09:33:28
    Number of times viewed: 1178

     
     
    //-----------------------------------------------------------------------
    //  File:		convertToUpper.cpp
    //
    //  Title:		Convert to Upper
    //
    //  Description:	Allow the user to input a sentence and then 
    //                   convert the sentence to uppercase for easy calculation,
    //                   and then display the number of times each letter of
    //                   the alphabet appeared in that sentence.
    //
    //  Programmer:		Mohamed Nuur
    //
    //  Date:			01/23/2001
    //
    //  Version:		1.0
    //
    //  Environment:
    //
    //     Hardware:		IBM PC compatible Pentium >= 133 MHZ with
    //                              1.44MB floppy disk, and 640 x 480 screen
    //				resolution.
    //
    //     Software:		Compiles: Microsoft Visual C++ 6.0
    //				Executes: DOS 6.2, Windows 98, Windows 2000
    //
    //  Function:		int main(void)
    //
    //	Called By:		None
    //
    //	Calls:		void convertToUpper(char* ch)
    //
    //  	Input:		Keyboard: char sentence[]: sentence to convert to uppercase
    //                                             by reference.
    //
    //  	Output:		Screen: User prompts: for entering a sentence, showing
    //                        result of number of letters in alphabet, and telling
    //                        user how to end the program.
    //
    //                              char sentence[]: sentence to test...
    //
    //                              int numberCubed: integer value of user's
    //                              number cubed
    //
    //  	Parameters:		None
    //
    //  	Returns:		int EXIT_SUCCESS: value returned to the operating
    //	                      system indicating successful program completion
    //
    //  	History Log:      1.0  01/18/2001  MN started original version
    //                        1.0  01/23/2001  MN completed original version
    //-----------------------------------------------------------------------
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <iostream.h>
    
    void convertToUpper(char* ch);
    
    const MAX_LENGTH = 80;
    const MAX_LETTERS = 26;
    
    int main(void)
    {
    	int i;
    	int letters[MAX_LETTERS] = {0};
    	char sentence[MAX_LENGTH + 1];
    	int temp = 'A';
    
    	cout << "Type Sentence Below:nnt: >> ";
    	cin.getline(sentence, MAX_LENGTH);
    
    	for( i = 0; sentence[i] != 0; i++ )
    	{
    		convertToUpper( &sentence[i] );
    		letters[ sentence[i] - temp ]++;
    	}
    
    	cout << "nn" << endl;
    
    	for( i = 0; i < MAX_LETTERS; i++ )
    	{
    		if( i % 5 == 0 )
    		{
    			cout << "n";
    		}
    		else
    		{
    			cout << "tt";
    		}
    
    		cout << (char)(i + temp) << ": " << letters[i];
    	}
    
    	cout << "nnThe EndnnPress <ENTER> to continue..." << endl;
    
    	cin.ignore();             //pause and clear buffer
    
    	return EXIT_SUCCESS;
    }
    
    
    //-----------------------------------------------------------------------
    //  Title:		Convert to Upper
    //
    //  Description:	Get a character (by reference) and check if it is
    //                          an uppercase or lowercase and then convert to
    //                          uppercase.
    //
    //  Programmer:		Mohamed Nuur
    //
    //  Date:			01/23/2001
    //
    //  Version:		1.0
    //
    //  Function:		void convertToUpper(char* ch)
    //
    //	Called By:		int main(void)
    //
    //	Calls:		None
    //
    //  	Input:		Keyboard: None
    //
    //  	Output:		Screen: None
    //
    //  	Parameters:		char* ch: by reference, the character that is converted
    //                                to uppercase.
    //
    //  	Returns:		None
    //-----------------------------------------------------------------------
    
    void convertToUpper(char* ch)
    {
    	if( *ch >= 'a' && *ch <= 'z' )
    	{
    		*ch -= ('a' - 'A');
    	}
    }

    Please Rate this Code:



     «12039» THINKQUEST TEAM C0111571 © 2001. All Rights Reserved.