1
\$\begingroup\$

This is my code:

#include <stdio.h>
#include <ctype.h>
int main()
{
 int ch;
 int numberOfCharacters = 0;
 printf("please enter a word, and ctrl + d to see the resault\n");
 while ((ch = getchar()) != EOF && isprint(ch))
 {
 numberOfCharacters++;
 }
 printf("The number of characters is %d", numberOfCharacters);
 return 0;
}

Is this a good code?

asked Feb 1, 2013 at 10:43
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Well, it doesn't do much. But it is not bad. A few issues:

  • main() should have parameters
  • excess blank lines (lines 5, 12, 16, 18) spoil the appearance
  • no \n on the last printf
  • the spec doesn't say 'printable' characters, just characters.
  • "please" needs a capital p and "resault" should be "result"
answered Feb 1, 2013 at 13:30
\$\endgroup\$
1
  • \$\begingroup\$ thank you! i know it dosent do much, but since im a newbie i would love to get feedback like you just wrote so i will know for next time or when i have bigger programs @WilliamMorris \$\endgroup\$ Commented Feb 1, 2013 at 13:54

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.