In this article I would like to share with you a simple string manipulation program that I wrote using C programming language I called this program count the number of capital and small letters in c. What the program will do is to ask the user to enter a word or sentence afterwards our program will count the number of occurrence of capital and small letters in a given word or sentence by our end user. The program is very simple it users while loop statement, pointers and one dimensional array to solve the problem.
If you ask me what type of C compiler that I am using in this program I am using Dev C++ that run in CodeBlocks text editor all this compiler can download free from charge over the Internet.
I hope you will find my work useful and beneficial in your learning how to program using C programming language. If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. You can reach me at my mobile number here in the Philippines at 09173084360.
Thank you very much and God Bless.
Sample Program Output
Program Listing
#include <stdio.h>
#include <stdlib.h>
char count_captial_small(char *y)
{
int upper_case_letters = 0, lower_case_letters = 0,counter=0;
counter = 0;
while (y[counter] != '\0') {
if (y[counter] >= 'A' && y[counter] <= 'Z')
upper_case_letters++;
if (y[counter] >= 'a' && y[counter] <= 'z')
lower_case_letters++;
counter++;
}
printf("\n\n");
printf("\t ===== DISPLAY RESULT =====");
printf("\n\n");
printf("\nNumber of Uppercase Letters ===> %d.", upper_case_letters);
printf("\nNumber of Lowercase Letters ===> %d.", lower_case_letters);
printf("\n\n");
printf("\t Thank you for this program.");
printf("\n\n");
}
int main() {
char ch[255];
printf("\tCount Capital and Small Letters in C");
printf("\n\n");
printf("\nKindly enter a Word or a Sentence :=> ");
gets(ch);
count_captial_small(ch);
return (0);
}
No comments:
Post a Comment