Character-counting Program doesn't work

write a c programm wich read a Line of character from the keypord then

Page 1 of 1

3 Replies - 601 Views - Last Post: 21 December 2010 - 06:05 PM Rate Topic: -----

#1 sesa2010  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-December 10

Character-counting Program doesn't work

Posted 21 December 2010 - 11:40 AM

Idonot no why it dosenot work?
write a c programm wich read a Line of character from the keypord then the programm displays how many
-uppercases characters
-lowercases characters
-digits
-spaces*/
#include<stdio.h>
int main()
{
char ch,u,l,d,s,o;
u=l=d=s=o=0;

ch=getchar();
while(ch!='\n')
if(ch>='A'&& ch<='z')u++;
  else if(ch>='a'&& ch<='z')l++;
      else if(ch>='0'&& ch<='9')d++;
      else if(ch==' '|| ch=='\t')s++;
      else o++;
      ch=getchar();
  {
      printf("nummber of  is:%d\n",u);
      printf("nummber of is: %d\n",l);
      printf("nummber of  is:%d\n",d);
      printf("nummber of  is:%d\n",s);
      printf("nummber of  is:%d\n",o);
  
   }
return 0;    
}

:bigsmile: Thanks for help

MOD EDIT: When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 21 December 2010 - 12:14 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Character-counting Program doesn't work

#2 JaKWaC  Icon User is offline

  • D.I.C Head

Reputation: 76
  • View blog
  • Posts: 234
  • Joined: 15-November 10

Re: Character-counting Program doesn't work

Posted 21 December 2010 - 11:57 AM

What doesnt work? Are you getting any errors, if so paste them exactly as your compiler shows them.

If there are no errors what ouput are you getting and what did you expect to get?

I can already tell you that your brackets are in the wrong place.

This post has been edited by JaKWaC: 21 December 2010 - 11:58 AM

Was This Post Helpful? 0
  • +
  • -

#3 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1335
  • View blog
  • Posts: 4,575
  • Joined: 19-February 09

Re: Character-counting Program doesn't work

Posted 21 December 2010 - 02:34 PM

What case should the character 'z' be.

if(ch>='A'&& ch<='z')u++;

Was This Post Helpful? 1
  • +
  • -

#4 sesa2010  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-December 10

Re: Character-counting Program doesn't work

Posted 21 December 2010 - 06:05 PM

thanks for help it works now at the beginning was very slowly
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1