The aim of this program is to learn more about the ctype.h library.
The program should give the user five attempts to enter lower case letters. It then checks the letter entered. if it is lower it will convert it into an upper case letter. This works fine so far.
Where i do have difficulties is that after the first time through the loop, i do not enter the second state of the loop but rather the third. I have looked into the code but found no errors hence i need assistance here.
Code:
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
//Write a simple application which makes sure every letter entered a lower case and then converted to upper case
int main(void)
{
char letter;
unsigned short int count_max = 5U;
unsigned short int count_min = 1u;
do
{
letter = 0;
printf("%d. Enter Alphabet : ", count_min);
scanf("%c", &letter);
//check if the letter entered is lower case. if so proceed and convert to upper case
if(islower(letter))
{
printf("You entered a lower case letter %c\n\n", toupper(letter));
}
else
{
printf("You entered an upper case letter. I only need lower case letters.\n\n");
}
printf("\n\n");
++count_min;
}while(count_min <= count_max);
//end of program
printf("This is the end of this program.\n\n");
//return control over to the os
return(0);
}