C , array [A string contains characters other than alphabets should consider as invalid], find errors, help?

  • Thread starter Thread starter Yashaswi gulati
  • Start date Start date
Y

Yashaswi gulati

Guest
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char s[50];
int i,flag=0,c;
printf("Enter the name:");
scanf(" %[^\n]s",s);
c=strlen(s);
for(i=0;i<c;i++)
{
if((s>='A' && s<='Z') || (s>='a' && s<='z'))
flag=0;
else
flag=1;
}
if(flag==1)
{
printf("Invalid name");
}

else
printf("The number of letters in the name is %d",c);

return 0;
}

Continue reading...
 
Back
Top