Wednesday, February 27, 2013

C Language Example # 27 Example : Count upper, lower and other characters

C Language Example # 27 Example : Count upper, lower and other characters.

* Program will count total number of upper letter, lower letter and other characters..

//Written by Latest Technology Guide    
//Title : C Language Example # 27 Example : Count upper, lower and other characters.

#include <stdio.h>
#include <conio.h>
#include <ctype.h>
void main()
{
clrscr();

int i=0,upper=0,lower=0,other=0;
char str[50];

printf("Enter String : ");
gets(str);

do{
if(isupper(str[i]))
upper++;
else if(islower(str[i]))
lower++;
else
other++;
}while(str[++i]!=NULL);

printf("\n\t\t\t : Character Summary is : \n");

printf("\n\t Upper Characters are : %d",upper);
printf("\n\t Lower Characters are : %d",lower);
printf("\n\t Other Characters are : %d",other);
printf("\n\t --------------------------");
printf("\n\t Total Characters are : %d",upper+lower+other);

getch();
}


Output:

* Program will display total number of upper letter.

* Program will display total number of lower letter.
* Program will display total number of other characters.

--------------------------------------------------------------------------------
Explanation of C Programming Language Example # 27 Example : Count upper, lower and other characters.

* Program will check one by one character and will compare with upper, lower and other character.
* After counting it will display upper letter, lower letter and other characters.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

No comments:

Post a Comment