94 : Print number of Uppercase and Lowercase and other characters in a String

Check out the complete list of c-programs : C Program List    












/*
 ============================================================================
 Name        : C-Programming
 Author      : Code2care
 Version     : 1.0
 Copyright   : Code2care.org
 Description : 94 : Print number of Uppercase and Lowercase and other characters in a String
 ============================================================================
 */

#include 
#include 

int main(void) {

	char ch;

	int upper = 0;
	int lower = 0;
	int others = 0;

	printf("Enter any sentence : ");

	while ((ch = getchar()) != '\n') {

		if (ch >= 'A' && ch <= 'Z') {
			upper = upper + 1;
		} else if (ch >= 'a' && ch <= 'z') {
			lower = lower + 1;
		} else {
			others = others + 1;
		}
	}
	printf("\nUppercase Characters : %d", upper);
	printf("\nLowercase Characters : %d", lower);
	printf("\nOthers : %d", others);
	return 0;
}









The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.