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. }