Write a program named “countletters” that counts the occurrences of all small an
ID: 3618933 • Letter: W
Question
Write a program named “countletters” that counts the occurrences of all small and capitalletters in given below string and then prints the result in theformat (Caps, count:: Small, count).Strings is“bcAdBDeCEad”and it should print this result (Caps, 5:: Small, 5).The programshould take address of the source string as a parameter via stackand also provide proper comments against each instruction. "Need this in Assembly language" Write a program named “countletters” that counts the occurrences of all small and capitalletters in given below string and then prints the result in theformat (Caps, count:: Small, count).Strings is“bcAdBDeCEad”and it should print this result (Caps, 5:: Small, 5).The programshould take address of the source string as a parameter via stackand also provide proper comments against each instruction. "Need this in Assembly language"Explanation / Answer
#include<iostream.h> #include<conio.h> void Count_Letters(char []); //functiondeclaration void main() { char string[20]; //string declaration cout<<" Enter the String :"; cin>>string; Count_Letters(string); //functioncall getche(); } void Count_Letters(char str[]) //function definition { int Caps=0,Small=0; //caps and small for counting theno of capital and small characters in the string for(int i=0;str[i]!='';i++) //loop will run till the end character for astring is not reached { if(str[i]>='A'&&str[i]<='Z') //if string has a capitalcharcter the the int cpas will be incremented Caps++; if(str[i]>='a'&&str[i]<='z') //if string has a small character thensmall would be incremented Small++; } cout<<" Caps,"<<Caps<<"::Small,"<<Small; //displaying the no ofcapital and small characters in string. }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.