K&R Answers?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zach

    K&R Answers?

    I recall someone posting a website that had the complete K&R (2nd Ed.
    - ANSI) answers posted but I cannot find the post.

    Zach
  • Richard Heathfield

    #2
    Re: K&R Answers?

    Zach said:
    I recall someone posting a website that had the complete K&R (2nd Ed.
    - ANSI) answers posted but I cannot find the post.
    Not complete (if I recall correctly) - but the Web site you're looking for
    is:

    <http://clc-wiki.net/wiki/K%26R2_solution s>

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Comment

    • Zach

      #3
      Re: K&amp;R Answers?

      On Mar 15, 8:09 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
      Zach said:
      >
      I recall someone posting a website that had the complete K&R (2nd Ed.
      - ANSI) answers posted but I cannot find the post.
      >
      Not complete (if I recall correctly) - but the Web site you're looking for
      is:
      >
      <http://clc-wiki.net/wiki/K%26R2_solution s>
      Thanks Richard.

      Zach

      Comment

      • stop

        #4
        Re: K&amp;R Answers?


        "Zach" <netrek@gmail.c omwrote in message
        news:3c8dd0c2-8f30-41ec-8b30-b3901442e7ee@n7 5g2000hsh.googl egroups.com...
        On Mar 15, 8:09 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
        >Zach said:
        >>
        I recall someone posting a website that had the complete K&R (2nd Ed.
        - ANSI) answers posted but I cannot find the post.
        >>
        >Not complete (if I recall correctly) - but the Web site you're looking
        >for
        >is:
        >>
        ><http://clc-wiki.net/wiki/K%26R2_solution s>
        >
        Thanks Richard.
        >
        Zach
        There's a worthwhile hard-copy available. _The C Solution Book_ About 3/8"
        thick and fewer errata than the covers of Unleashed.

        I'm curious what's at that link.
        --
        "A man is accepted into church for what he believes--and turned out for
        what he knows."

        -Mark Twain


        Comment

        • santosh

          #5
          Re: K&amp;R Answers?

          stop wrote:
          >
          "Zach" <netrek@gmail.c omwrote in message
          >
          news:3c8dd0c2-8f30-41ec-8b30-b3901442e7ee@n7 5g2000hsh.googl egroups.com...
          >On Mar 15, 8:09 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
          >>Zach said:
          >>>
          >I recall someone posting a website that had the complete K&R (2nd
          >Ed. - ANSI) answers posted but I cannot find the post.
          >>>
          >>Not complete (if I recall correctly) - but the Web site you're
          >>looking for
          >>is:
          >>>
          >><http://clc-wiki.net/wiki/K%26R2_solution s>
          >>
          >Thanks Richard.
          There's a worthwhile hard-copy available. _The C Solution Book_
          About 3/8" thick and fewer errata than the covers of Unleashed.
          Do you mean /The C Answer Book/ by Clovis & Tondo?
          I'm curious what's at that link.
          Solutions to some of the exercises in K&R2, contributed by various clc
          participants.

          Comment

          • Ioannis Vranos

            #6
            Re: K&amp;R Answers?

            Zach wrote:
            I recall someone posting a website that had the complete K&R (2nd Ed.
            - ANSI) answers posted but I cannot find the post.

            Well about a K&R2 exercise posted in another thread. I think the answer:



            #include <stdio.h>
            #include <limits.h>

            int
            main ()
            {
            printf("Size of Char %d\n", CHAR_BIT);
            printf("Size of Char Max %d\n", CHAR_MAX);
            printf("Size of Char Min %d\n", CHAR_MIN);
            printf("Size of int min %d\n", INT_MIN);
            printf("Size of int max %d\n", INT_MAX);
            printf("Size of long min %ld\n", LONG_MIN); /* RB */
            printf("Size of long max %ld\n", LONG_MAX); /* RB */
            printf("Size of short min %d\n", SHRT_MIN);
            printf("Size of short max %d\n", SHRT_MAX);
            printf("Size of unsigned char %u\n", UCHAR_MAX); /* SF */
            printf("Size of unsigned long %lu\n", ULONG_MAX); /* RB */
            printf("Size of unsigned int %u\n", UINT_MAX); /* RB */
            printf("Size of unsigned short %u\n", USHRT_MAX); /* SF */

            return 0;
            }


            is wrong and a bit incomplete.


            I think the correct one is:


            #include <stdio.h>
            #include <limits.h>

            int main ()
            {
            printf("Size of Char %d\n", CHAR_BIT);
            printf("Size of Char Max %d\n", CHAR_MAX);
            printf("Size of Char Min %d\n", CHAR_MIN);
            printf("Size of int min %d\n", INT_MIN);
            printf("Size of int max %d\n", INT_MAX);
            printf("Size of long min %ld\n", LONG_MIN); /* RB */
            printf("Size of long max %ld\n", LONG_MAX); /* RB */
            printf("Size of short min %d\n", SHRT_MIN);
            printf("Size of short max %d\n", SHRT_MAX);
            == printf("Size of unsigned char max %u\n", (unsigned) UCHAR_MAX);
            == printf("Size of unsigned long max %lu\n", ULONG_MAX); /* RB */
            == printf("Size of unsigned int max %u\n", UINT_MAX); /* RB */
            == printf("Size of unsigned short max %u\n", USHRT_MAX); /* SF */

            return 0;
            }

            Comment

            • Ioannis Vranos

              #7
              Re: K&amp;R Answers?

              Ioannis Vranos wrote:
              Zach wrote:
              >I recall someone posting a website that had the complete K&R (2nd Ed.
              >- ANSI) answers posted but I cannot find the post.
              >
              >
              Well about a K&R2 exercise posted in another thread. I think the answer:
              >

              >
              #include <stdio.h>
              #include <limits.h>
              >
              int
              main ()
              {
              printf("Size of Char %d\n", CHAR_BIT);
              printf("Size of Char Max %d\n", CHAR_MAX);
              printf("Size of Char Min %d\n", CHAR_MIN);
              printf("Size of int min %d\n", INT_MIN);
              printf("Size of int max %d\n", INT_MAX);
              printf("Size of long min %ld\n", LONG_MIN); /* RB */
              printf("Size of long max %ld\n", LONG_MAX); /* RB */
              printf("Size of short min %d\n", SHRT_MIN);
              printf("Size of short max %d\n", SHRT_MAX);
              printf("Size of unsigned char %u\n", UCHAR_MAX); /* SF */
              printf("Size of unsigned long %lu\n", ULONG_MAX); /* RB */
              printf("Size of unsigned int %u\n", UINT_MAX); /* RB */
              printf("Size of unsigned short %u\n", USHRT_MAX); /* SF */
              >
              return 0;
              }
              >
              >
              is wrong and a bit incomplete.
              >
              >
              I think the correct one is:

              More:

              #include <stdio.h>
              #include <limits.h>
              >
              int main ()
              {
              == printf("Bits of Char %d\n", CHAR_BIT);
              printf("Size of Char Max %d\n", CHAR_MAX);
              printf("Size of Char Min %d\n", CHAR_MIN);
              printf("Size of int min %d\n", INT_MIN);
              printf("Size of int max %d\n", INT_MAX);
              printf("Size of long min %ld\n", LONG_MIN); /* RB */
              printf("Size of long max %ld\n", LONG_MAX); /* RB */
              printf("Size of short min %d\n", SHRT_MIN);
              printf("Size of short max %d\n", SHRT_MAX);
              == printf("Size of unsigned char max %u\n", (unsigned) UCHAR_MAX);
              == printf("Size of unsigned long max %lu\n", ULONG_MAX); /* RB */
              == printf("Size of unsigned int max %u\n", UINT_MAX); /* RB */
              == printf("Size of unsigned short max %u\n", USHRT_MAX); /* SF */
              >
              return 0;
              }

              Comment

              • Richard Heathfield

                #8
                Re: K&amp;R Answers?

                Ioannis Vranos said:

                <snip>
                >
                Well about a K&R2 exercise posted in another thread. I think the answer:
                >

                >
                <snip>
                >
                is wrong and a bit incomplete.
                Then why not submit your own version to the C wiki?

                --
                Richard Heathfield <http://www.cpax.org.uk >
                Email: -http://www. +rjh@
                Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                "Usenet is a strange place" - dmr 29 July 1999

                Comment

                • Ioannis Vranos

                  #9
                  Re: K&amp;R Answers?

                  Richard Heathfield wrote:
                  Ioannis Vranos said:
                  >
                  <snip>
                  >Well about a K&R2 exercise posted in another thread. I think the answer:
                  >>
                  >http://clc-wiki.net/wiki/K%26R2_solu...r_2:Exercise_1
                  >>
                  <snip>
                  >is wrong and a bit incomplete.
                  >
                  Then why not submit your own version to the C wiki?

                  I can't find out how to create an account.

                  Comment

                  • Ioannis Vranos

                    #10
                    Re: K&amp;R Answers?

                    Richard Heathfield wrote:
                    >
                    Then why not submit your own version to the C wiki?

                    OK, I edited the text.

                    Comment

                    • Flash Gordon

                      #11
                      Re: K&amp;R Answers?

                      Ioannis Vranos wrote, On 16/03/08 15:45:
                      Richard Heathfield wrote:
                      >Ioannis Vranos said:
                      >>
                      ><snip>
                      >>Well about a K&R2 exercise posted in another thread. I think the answer:
                      >>>
                      >>http://clc-wiki.net/wiki/K%26R2_solu...r_2:Exercise_1
                      >>>
                      ><snip>
                      >>is wrong and a bit incomplete.
                      >>
                      >Then why not submit your own version to the C wiki?
                      >
                      I can't find out how to create an account.
                      There is a box in the top right corner which when you hover the mouse
                      over it will give you the login/creat account options. Alternatively
                      alt+shift+O should work. Email me if you still have problems.
                      --
                      Flash Gordon
                      Providing the server for the CLC Wiki

                      Comment

                      • Keith Thompson

                        #12
                        Re: K&amp;R Answers?

                        Ioannis Vranos <ivranos@nospam .no.spamfreemai l.grwrites:
                        Zach wrote:
                        >I recall someone posting a website that had the complete K&R (2nd Ed.
                        >- ANSI) answers posted but I cannot find the post.
                        >
                        Well about a K&R2 exercise posted in another thread. I think the answer:
                        >

                        >
                        #include <stdio.h>
                        #include <limits.h>
                        >
                        int
                        main ()
                        {
                        printf("Size of Char %d\n", CHAR_BIT);
                        printf("Size of Char Max %d\n", CHAR_MAX);
                        printf("Size of Char Min %d\n", CHAR_MIN);
                        printf("Size of int min %d\n", INT_MIN);
                        printf("Size of int max %d\n", INT_MAX);
                        printf("Size of long min %ld\n", LONG_MIN); /* RB */
                        printf("Size of long max %ld\n", LONG_MAX); /* RB */
                        printf("Size of short min %d\n", SHRT_MIN);
                        printf("Size of short max %d\n", SHRT_MAX);
                        printf("Size of unsigned char %u\n", UCHAR_MAX); /* SF */
                        printf("Size of unsigned long %lu\n", ULONG_MAX); /* RB */
                        printf("Size of unsigned int %u\n", UINT_MAX); /* RB */
                        printf("Size of unsigned short %u\n", USHRT_MAX); /* SF */
                        >
                        return 0;
                        }
                        >
                        >
                        is wrong and a bit incomplete.
                        >
                        >
                        I think the correct one is:
                        [snip]

                        The more serious problem is that the messages are worded incorrectly.
                        It prints, for example (on my system):

                        Size of int max 2147483647

                        2147483647 is not a size, it's an upper bound.

                        The two lines
                        printf("Size of int min %d\n", INT_MIN);
                        printf("Size of int max %d\n", INT_MAX);
                        should be replaced with something like:
                        printf("Range of int is %d to %d\n", INT_MIN, INT_MAX);

                        --
                        Keith Thompson (The_Other_Keit h) <kst-u@mib.org>
                        Nokia
                        "We must do something. This is something. Therefore, we must do this."
                        -- Antony Jay and Jonathan Lynn, "Yes Minister"

                        Comment

                        • Ioannis Vranos

                          #13
                          Re: K&amp;R Answers?

                          Keith Thompson wrote:
                          >
                          The more serious problem is that the messages are worded incorrectly.
                          It prints, for example (on my system):
                          >
                          Size of int max 2147483647
                          >
                          2147483647 is not a size, it's an upper bound.
                          >
                          The two lines
                          printf("Size of int min %d\n", INT_MIN);
                          printf("Size of int max %d\n", INT_MAX);
                          should be replaced with something like:
                          printf("Range of int is %d to %d\n", INT_MIN, INT_MAX);

                          Fixed. I think your contribution is made clear in the text, if not
                          please post a reply.

                          Comment

                          • stop

                            #14
                            Re: K&amp;R Answers?



                            "santosh" <santosh.k83@gm ail.comwrote in message
                            news:fri6kr$n8n $2@registered.m otzarella.org.. .
                            stop wrote:
                            >
                            >>
                            >"Zach" <netrek@gmail.c omwrote in message
                            >>
                            news:3c8dd0c2-8f30-41ec-8b30-b3901442e7ee@n7 5g2000hsh.googl egroups.com...
                            >>On Mar 15, 8:09 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
                            >>>Zach said:
                            >>>>
                            >>I recall someone posting a website that had the complete K&R (2nd
                            >>Ed. - ANSI) answers posted but I cannot find the post.
                            >>>>
                            >>>Not complete (if I recall correctly) - but the Web site you're
                            >>>looking for
                            >>>is:
                            >>>>
                            >>><http://clc-wiki.net/wiki/K%26R2_solution s>
                            >>>
                            >>Thanks Richard.
                            >
                            >There's a worthwhile hard-copy available. _The C Solution Book_
                            >About 3/8" thick and fewer errata than the covers of Unleashed.
                            >
                            Do you mean /The C Answer Book/ by Clovis & Tondo?
                            Yup. I dug it out today while I was moving crates of books. It's more like
                            5/8".

                            The authors are Tondo and Gimpel. Mr. Tondo's first name is Clovis. I'm
                            reasonably certain I've never met a Clovis before.

                            --
                            "A man is accepted into church for what he believes--and turned out for
                            what he knows."

                            -Mark Twain


                            Comment

                            • santosh

                              #15
                              Re: K&amp;R Answers?

                              stop wrote:
                              "santosh" <santosh.k83@gm ail.comwrote in message
                              news:fri6kr$n8n $2@registered.m otzarella.org.. .
                              <snip>
                              >Do you mean /The C Answer Book/ by Clovis & Tondo?
                              Yup. I dug it out today while I was moving crates of books. It's
                              more like 5/8".
                              >
                              The authors are Tondo and Gimpel. Mr. Tondo's first name is Clovis.
                              I'm reasonably certain I've never met a Clovis before.
                              You are right, thanks.

                              Comment

                              Working...