hi everyone! i've been trying to make a program regarding returning the number of characters with even ASCII codes. For example, if a user input ABCDE, the output should be 2 since B and D are of even ASCII codes.
Here's what i've done so far...
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int CountEvenASCII(char []);
void main()
{
char words[100],i,out;
clrscr();
for(i=0;i<100;i++);{
printf("Enter a word: ");
scanf("%c",&words[i]);}
atoi(&words[i]);}
printf("ASCII equivalent: %d",words[i]);
out=CountEvenASCII(words);
printf("\nNumber of characters with even ASCII codes: %d", out);
getch();
}
int CountEvenASCII(char str[])
{
int even_count=0,i;
if(str[0]!=NULL){
if(str[i]%2==0){
even_count++;
CountEvenASCII(&str[1]);
}
return even_count;
}
my problem is it can only return the ASCII equivalent of the first character. For example, if i try to input ABCDE.. the output is 65 instead of 65 66 67..... And also, even if A's ASCII equivalent is an odd number, the program still counts it as an even.. Any idea what I can do about this? Any help with be very much appreciated.