Plz refer to my program as given below. in this program whatever letter i give as an input for eg "input= Manav Kumar ". the count alphabet should comes 10 but it always comes 0 which is wrong. kindly tell me where did I do a mistake ?
#include <stdio.h>
#include<string.h>
int main()
{
int i,c=0;
char s[80];
printf(“Enter String=”);
scanf("%[^\n]",s);
for(i=0;s[i]!=’\0’;i++);
{
if((s[i]>=‘A’ && s[i]<=‘Z’)||(s[i]>=‘a’&& s[i]<=‘z’))
c++;
}
printf("Number of letter=%d",c);
return 0;
}
either provide an ideone link of your code or try putting your code inside ```and ``` so that its easier to read and can be copied to any editors
Now i do it. you can easily copy it.
What were you giving as input because it sure seems to work in my pc
Heres the code
#include <stdio.h>
#include <string.h>
int main()
{
int i, c = 0;
char s[80];
printf("Enter String =");
scanf("%[^\n]", s);
for(i = 0 ; s[i] != '\0' ; i++)
{
if((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z'))
c++;
}
printf("Number of letter = %d", c);
return 0;
}
I dont know how your program give wright answer to you even to me.
Plz take a look into the image where it give me the wrong answer. kindly check it.
but when i copy-paste your program & then run it gives me the correct answer its a miracle!!
I dont know where i did mistake. plz tell me my mistake in the program which i copy paste below.
Please provide an ideone link of your code