dimanche 29 mars 2015

checking if the characters in a string are either alphabets, numbers, or special characters. in c

i have been working on a question which asks to check the numbers,alphabets or other special characters in a string. for example if you are given two inputs. one is an integer which is string length and the second input is the string of characters. input1; 6 input2; 4!hs%5.


the output should be; noaaon. (n stands for number, a stands for alphabets, and o stands for other. i would appreciate if someone could help me .below is my code.



enter code here


`#include


include


int main(){


char c[20];


int n,i;


scanf("%d %s",&n,c);


for(i=1;c[i]<=n;i++)



if(i>='a' && i<='z')


printf("%c\n",(c[i]));


if(i=='!')printf("%c \n",i);


else{printf("%c \n",);}


return 0;} `


Aucun commentaire:

Enregistrer un commentaire