I'm trying to check if all the upper-case letters are present in the input the user entered.
I tried to make an array of 26 values, 0 will represent A and 25 is Z. At first I initialize the values to 0.
After that I asked the user for input and then I checked if it matches with the ASCII. If yes, I changed the array value to 1.
After that, I make sure all the array values are 1; if yes all the letters were in the input.
I assume that the user will end the input with 0.
The input is "THE Q$@UICK BROWN FOX JUMPS OVER tHe LAZY DOG!0".
This is the code:
#include <stdio.h>
int main()
{
int z;
int x = 1;
int arr[26] = {0};
printf("enter a sentance to check if all latter in ABC are in the sentance (in upper case):\n");
while (x!=0) {
scanf(" %d", &x);
z = x - 65;
if (z>=0 && z<=25) {
arr[z]=1;
}
}
z=0;
while (arr[z]==1 && z<26) {
++z;
if (z==26) {
printf("all the ABC in ur sentance\n");
break;
}
}
printf("all the ABC does not in ur sentance\n");
return 0;
}
There is no output and I think it's because there is a problem with the scanf, but I don't know how to solve it.