Make a program that will read a string and after that it determine the total of the letters, total of spaces,total digits,and total characters. example: i enter a string, hi 123 and the output is like this:TOTAL LETTERS:2TOTAL SPACES:2TOTAL DIGITS:3TOTAL CHARACTERS:7 pls. help me i need the answer a.s.a.p. thank you.

Showing Answers 1 - 2 of 2 Answers

sagar

  • Aug 28th, 2006
 

i assume that the string is in an array...

you can compare the individual value with the range of ascii values and then decide if it is a space or a letter or a number.

  Was this answer useful?  Yes

Santhosh

  • Oct 30th, 2006
 

#include#includemain(){ char a[30]; int n,i; int ns=0,nl=0,nd=0; printf("n enter the string: "); gets(a); n=strlen(a); for(i=0;i='a')&&(a[i]<='z')) nl++; else if((a[i]>='0')&&(a[i]<='9')) nd++; else if(a[i]==' ') ns++; printf("nno of digits: %d",nd); printf("nno of letters: %d",nl); printf("nno of spaces: %d",ns); printf("ntotal no of characters: %d",n);}output: enter the string: hi santhu538 how r uno of digits: 3no of letters: 13no of spaces: 4total no of characters: 20

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions