I am trying to construct a loop that will return the amount of lower case letters within a input, for example if the input were abc123, the input would return 3.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <string.h>
#include <iostream>
usingnamespace std;
int main(){
// create a string
string s("The man is fit");
cout << s << endl;
}
I have not got very far and hit a snag, I have tried to output this string and it fails on the build but I dont know why
I would use a loop to go through each character in the string, then use an if statement to check if the letter is lowercase (by checking if its ASCII value is between 97-122, this is the range for lowercase letters)
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
main()
{
char c[65];int i=0,j=0;
printf("/n/nplease enter your string");
scanf("%[ -z]",c); /*to select the characters entered as valid or invalid [a-b]...
a is the starting character and b is the ending character in the sequence of ASCII table
for eg if u write [A-B] it means ASCII A-65 to ASCII Z-90 [ -z] wud mean
ASCII space to ASCII small z */
while(c[i]!='\0')
{if ((islower(c[i]))>0) //to check whe
{j++;}
i++;
}
printf("The number of lower case characters that were found in the string entered were %d",j);
getch();
}