445,819 Members | 1,185 Online
Need help? Post your question and get tips & solutions from a community of 445,819 IT Pros & Developers. It's quick & easy.

# From vasanth

 P: n/a The first exercise of mine:/* Write a C-program to print the vaue of the alphabet when an integet value is entered .. For example if 1 is entered then A must be printed on the screen,if 2 is printed then B must be printed...like this so on......*/ Mar 17 '07 #1
11 Replies

 P: n/a va*******@gmail.com wrote: The first exercise of mine:/* Write a C-program to print the vaue of the alphabet when an integet value is entered .. For example if 1 is entered then A must be printed on the screen,if 2 is printed then B must be printed...like this so on......*/ Do you have a question? -- Eric Sosman es*****@acm-dot-org.invalid Mar 17 '07 #2

 P: n/a

 P: n/a va*******@gmail.com wrote: The first exercise of mine:/* Write a C-program to print the vaue of the alphabet when an integet value is entered .. For example if 1 is entered then A must be printed on the screen,if 2 is printed then B must be printed...like this so on......*/ What a dumb exercise. You need to throw away the material from which you got that exercise and buy a good C text like K&R2. Mar 17 '07 #4

 P: n/a santosh wrote: va*******@gmail.com wrote: The first exercise of mine:/* Write a C-program to print the vaue of the alphabet when an integet value is entered .. For example if 1 is entered then A must be printed on the screen,if 2 is printed then B must be printed...like this so on......*/ What a dumb exercise. You need to throw away the material from which you got that exercise and buy a good C text like K&R2. Most newbie exercises are fairly dumb. I don't see any particular objection to this one. Brian Mar 17 '07 #5

 P: n/a va*******@gmail.com wrote: > The first exercise of mine:/* Write a C-program to print the vaue of the alphabet when an integet value is entered .. For example if 1 is entered then A must be printed on the screen,if 2 is printed then B must be printed...like this so on......*/ /* BEGIN new.c */ #include int main(void) { int integet_value, rc; puts("Enter an integer from 1 to 26."); rc = scanf("%d", &integet_value); while (rc == 1 && integet_value 0 && 27 integet_value) { printf("The number %d letter of the alphabet is %c.\n\n", integet_value, " ABCDEFGHIJKLMNOPQRSTUVWYXYZ"[integet_value]); puts("Enter an integer from 1 to 26 to continue\n" "or any other integer to quit."); rc = scanf("%d", &integet_value); } return 0; } /* END new.c */ -- pete Mar 18 '07 #6

 P: n/a "Default User" va*******@gmail.com wrote: The first exercise of mine:/* Write a C-program to print the vaue of the alphabet when an integet value is entered .. For example if 1 is entered then A must be printed on the screen,if 2 is printed then B must be printed...like this so on......*/ What a dumb exercise. You need to throw away the material from whichyou got that exercise and buy a good C text like K&R2. Most newbie exercises are fairly dumb. I don't see any particular objection to this one. It tempts the newbie to assume that the character encoding is in alphabetical order. -- Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm Mar 18 '07 #7

 P: n/a Malcolm McLean wrote: "Default User" >va*******@gmail.com wrote:The first exercise of mine:/* Write a C-program to print thevaue of the alphabet when an integet value is entered .. Forexample if 1 is entered then A must be printed on the screen,if2 is printed then B must be printed...like this so on......*/What a dumb exercise. You need to throw away the material fromwhich you got that exercise and buy a good C text like K&R2. Most newbie exercises are fairly dumb. I don't see any particularobjection to this one. It tempts the newbie to assume that the character encoding is in alphabetical order. On the contrary, it demonstrates how to avoid such (erroneous) assumptions. -- Chuck F (cbfalconer at maineline dot net) Available for consulting/temporary embedded and systems. -- Posted via a free Usenet account from http://www.teranews.com Mar 18 '07 #8

 P: n/a Malcolm McLean wrote: "Default User" >va*******@gmail.com wrote:The first exercise of mine:/* Write a C-program to print the vaue ofthe alphabet when an integet value is entered .. For example if 1 isentered then A must be printed on the screen,if 2 is printed then Bmust be printed...like this so on......*/What a dumb exercise. You need to throw away the material from whichyou got that exercise and buy a good C text like K&R2. Most newbie exercises are fairly dumb. I don't see any particularobjection to this one. It tempts the newbie to assume that the character encoding is in alphabetical order. ... and offers an learning opportunity in overturning the tempting assumption. Temptation need not be a bad thing; read "The Man That Corrupted Hadleyburg." -- Eric Sosman es*****@acm-dot-org.invalid Mar 18 '07 #9

 P: n/a Malcolm McLean wrote: "Default User" >the alphabet when an integet value is entered .. For example if 1 is >>entered then A must be printed on the screen,if 2 is printed then B >>must be printed...like this so on......*/ > What a dumb exercise. You need to throw away the material from which you got that exercise and buy a good C text like K&R2. Most newbie exercises are fairly dumb. I don't see any particular objection to this one. It tempts the newbie to assume that the character encoding is in alphabetical order. I don't see how. There is such a thing as alphabetical order, and mapping that to integers seems natural. It doesn't say anything about the order of alpha characters in the particular character encoding used. If the student solved the problem in a way that used ASCII or something, then they should be marked down for a non-portable solution. There is a fairly straight-forward method that achieves it portably. Brian Mar 18 '07 #10

 P: n/a pete skrev: va*******@gmail.com wrote: >The first exercise of mine:/* Write a C-program to print the vaue ofthe alphabet when an integet value is entered .. For example if 1 isentered then A must be printed on the screen,if 2 is printed then Bmust be printed...like this so on......*/ /* BEGIN new.c */ #include int main(void) { int integet_value, rc; puts("Enter an integer from 1 to 26."); You probably mean: "Enter an integet...". rc = scanf("%d", &integet_value); while (rc == 1 && integet_value 0 && 27 integet_value) { printf("The number %d letter of the alphabet is %c.\n\n", integet_value, " ABCDEFGHIJKLMNOPQRSTUVWYXYZ"[integet_value]); puts("Enter an integer from 1 to 26 to continue\n" "or any other integer to quit."); rc = scanf("%d", &integet_value); } return 0; } /* END new.c */ August Mar 19 '07 #11

 P: n/a August Karlstrom wrote: > pete skrev: va*******@gmail.com wrote: The first exercise of mine:/* Write a C-program to print the vaue of the alphabet when an integet value is entered .. For example if 1 is entered then A must be printed on the screen,if 2 is printed then B must be printed...like this so on......*/ /* BEGIN new.c */ #include int main(void) { int integet_value, rc; puts("Enter an integer from 1 to 26."); You probably mean: "Enter an integet...". I try to be careful, but sometimes I slip up. rc = scanf("%d", &integet_value); while (rc == 1 && integet_value 0 && 27 integet_value) { -- pete Mar 19 '07 #12

### This discussion thread is closed

Replies have been disabled for this discussion.