Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #96410 > unrolled thread

The assignment for today's lesson

Started by"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
First post2016-11-12 19:10 +0800
Last post2016-11-13 21:48 -0500
Articles 20 on this page of 33 — 12 participants

Back to article view | Back to comp.lang.c

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  The assignment for today's lesson "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-12 19:10 +0800
    Re: The assignment for today's lesson Robert Spanjaard <spamtrap@arumes.com> - 2016-11-12 16:38 +0100
      Re: The assignment for today's lesson "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-12 23:43 +0800
        Re: The assignment for today's lesson Robert Spanjaard <spamtrap@arumes.com> - 2016-11-12 21:36 +0100
          Re: The assignment for today's lesson "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 14:30 +0800
            Re: The assignment for today's lesson Your Name <YourName@YourISP.com> - 2016-11-13 19:37 +1300
              [OT] chat "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 14:40 +0800
                Re: [OT] chat Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2016-11-13 08:58 +0100
                  Re: [OT] chat "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 18:46 +0800
            Re: The assignment for today's lesson Robert Spanjaard <spamtrap@arumes.com> - 2016-11-13 11:25 +0100
              Re: The assignment for today's lesson "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 18:47 +0800
          Re: New assignment/homework "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 14:32 +0800
            Re: New assignment/homework Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-13 10:05 +0000
              [OT] "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-13 18:47 +0800
          Re: The assignment for today's lesson Ike Naar <ike@iceland.freeshell.org> - 2016-11-13 20:48 +0000
            Re: The assignment for today's lesson Robert Spanjaard <spamtrap@arumes.com> - 2016-11-13 22:29 +0100
              Re: The assignment for today's lesson "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-13 16:38 -0500
                Re: The assignment for today's lesson Gareth Owen <gwowen@gmail.com> - 2016-11-13 22:24 +0000
            Re: The assignment for today's lesson "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-13 16:37 -0500
              Re: The assignment for today's lesson Ike Naar <ike@iceland.freeshell.org> - 2016-11-14 09:39 +0000
          Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-13 19:07 -0500
            Re: The assignment for today's lesson Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-11-13 19:42 -0500
              Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-13 21:47 -0500
                Re: The assignment for today's lesson Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-11-14 10:39 -0500
                  Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-14 11:38 -0500
                  Re: The assignment for today's lesson "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-14 12:15 -0500
                    Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-14 16:01 -0500
              Re: The assignment for today's lesson Richard Damon <Richard@Damon-Family.org> - 2016-11-13 22:25 -0500
                Re: The assignment for today's lesson Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-14 12:05 +0000
              Re: The assignment for today's lesson "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-14 12:14 -0500
                Re: The assignment for today's lesson Keith Thompson <kst-u@mib.org> - 2016-11-14 09:50 -0800
            Re: The assignment for today's lesson Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-14 00:42 +0000
              Re: The assignment for today's lesson Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-13 21:48 -0500

Page 1 of 2  [1] 2  Next page →


#96410 — The assignment for today's lesson

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2016-11-12 19:10 +0800
SubjectThe assignment for today's lesson
Message-ID<o06tan$db7$1@dont-email.me>
On 12/11/2016 7:04 PM, REVOLUTION ANTI NAZIMAFIOSO DONALD TRUMP wrote:
 >
> ... crap ...

Apprentices and Pandawans, we have a load of crap here. I do not wanna 
repeat nor quote it here.

Write a simple C program to count the letters and numbers in this load 
of crap.

Please, I beg you all, do NOT copy and paste existing solutions. Use 
your brain! :)

[toc] | [next] | [standalone]


#96414

FromRobert Spanjaard <spamtrap@arumes.com>
Date2016-11-12 16:38 +0100
Message-ID<o07d1c$1fbu$1@gioia.aioe.org>
In reply to#96410
On 12-11-16 12:10, Mr. Man-wai Chang wrote:
>> ... crap ...
>
> Apprentices and Pandawans, we have a load of crap here. I do not wanna
> repeat nor quote it here.
>
> Write a simple C program to count the letters and numbers in this load
> of crap.
>
> Please, I beg you all, do NOT copy and paste existing solutions. Use
> your brain! :)

I can't. System reports a Clown Overflow everytime it encounters "trump".

-- 
Robert Spanjaard

[toc] | [prev] | [next] | [standalone]


#96415

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2016-11-12 23:43 +0800
Message-ID<o07d9c$331$2@dont-email.me>
In reply to#96414
On 12/11/2016 11:38 PM, Robert Spanjaard wrote:
>
> I can't. System reports a Clown Overflow everytime it encounters "trump".
>

You are NOT doing the homework. :)

[toc] | [prev] | [next] | [standalone]


#96426

FromRobert Spanjaard <spamtrap@arumes.com>
Date2016-11-12 21:36 +0100
Message-ID<o07ug8$bv6$1@gioia.aioe.org>
In reply to#96415
On 12-11-16 16:43, Mr. Man-wai Chang wrote:
> On 12/11/2016 11:38 PM, Robert Spanjaard wrote:
>>
>> I can't. System reports a Clown Overflow everytime it encounters "trump".
>>
>
> You are NOT doing the homework. :)

Ok, ok...

#include <stdio.h>

int main()
{	
    char	chewb;	/* current character being processed */
    int	r2d2,	/* number of numbers */
    	c3po;	/* number of letters */

    while ((chewb = getchar()) != EOF)
       if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))
          ++c3po;
       else if (chewb >= '0' && chewb <= '9')
          ++r2d2;

    printf("Number of letters: %i\nNumber of numbers: %i\n", c3po, r2d2);
    return 0;
}

Be careful to only run this once. Chewbacca doesn't like doing all the hard
work, and letting the droids get away with the results.

-- 
Robert Spanjaard

[toc] | [prev] | [next] | [standalone]


#96451

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2016-11-13 14:30 +0800
Message-ID<o091a3$662$6@dont-email.me>
In reply to#96426
On 13/11/2016 4:36 AM, Robert Spanjaard wrote:
> #include <stdio.h>
>
> int main()
> {
>    char    chewb;    /* current character being processed */
>    int    r2d2,    /* number of numbers */
>        c3po;    /* number of letters */
>
>    while ((chewb = getchar()) != EOF)
>       if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))
>          ++c3po;
>       else if (chewb >= '0' && chewb <= '9')
>          ++r2d2;
>
>    printf("Number of letters: %i\nNumber of numbers: %i\n", c3po, r2d2);
>    return 0;
> }

Thanks! Need I compile this specific C program using a specific C 
compiler?  :)

[toc] | [prev] | [next] | [standalone]


#96453

FromYour Name <YourName@YourISP.com>
Date2016-11-13 19:37 +1300
Message-ID<131120161937373119%YourName@YourISP.com>
In reply to#96451
In article <o091a3$662$6@dont-email.me>, Mr. Man-wai Chang
<toylet.toylet@gmail.com> wrote:
> On 13/11/2016 4:36 AM, Robert Spanjaard wrote:
> > #include <stdio.h>
> >
> > int main()
> > {
> >    char    chewb;    /* current character being processed */
> >    int    r2d2,    /* number of numbers */
> >        c3po;    /* number of letters */
> >
> >    while ((chewb = getchar()) != EOF)
> >       if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))
> >          ++c3po;
> >       else if (chewb >= '0' && chewb <= '9')
> >          ++r2d2;
> >
> >    printf("Number of letters: %i\nNumber of numbers: %i\n", c3po, r2d2);
> >    return 0;
> > }
> 
> Thanks! Need I compile this specific C program using a specific C 
> compiler?  :)

Please do not cross-post this C rubbish to alt.fan.starwars
C is a disgusting programming language anyway - use a real programming
language like Pascal or BASIC  :-p

[toc] | [prev] | [next] | [standalone]


#96454 — [OT] chat

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2016-11-13 14:40 +0800
Subject[OT] chat
Message-ID<o091sm$662$12@dont-email.me>
In reply to#96453
On 13/11/2016 2:37 PM, Your Name wrote:
>
> Please do not cross-post this C rubbish to alt.fan.starwars
> C is a disgusting programming language anyway - use a real programming
> language like Pascal or BASIC  :-p

Wanna teach some Pandawans to program in C.

Would Donald Trump master C programming as an Apprentice? :)

[toc] | [prev] | [next] | [standalone]


#96455 — Re: [OT] chat

FromSjouke Burry <burrynulnulfour@ppllaanneett.nnll>
Date2016-11-13 08:58 +0100
SubjectRe: [OT] chat
Message-ID<58281d27$0$1781$e4fe514c@textnews.kpn.nl>
In reply to#96454
On 13.11.16 7:40, Mr. Man-wai Chang wrote:
> On 13/11/2016 2:37 PM, Your Name wrote:
>>
>> Please do not cross-post this C rubbish to alt.fan.starwars
>> C is a disgusting programming language anyway - use a real programming
>> language like Pascal or BASIC  :-p
>
> Wanna teach some Pandawans to program in C.
>
> Would Donald Trump master C programming as an Apprentice? :)
>
Who would employ him as apprentice? There are less painful ways to
ruin your biz.

[toc] | [prev] | [next] | [standalone]


#96460 — Re: [OT] chat

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2016-11-13 18:46 +0800
SubjectRe: [OT] chat
Message-ID<o09g95$kuu$5@dont-email.me>
In reply to#96455
On 13/11/2016 3:58 PM, Sjouke Burry wrote:
>>
>> Would Donald Trump master C programming as an Apprentice? :)
>>
> Who would employ him as apprentice? There are less painful ways to
> ruin your biz.

But right now, he's The Apprentice of President Obama! :)

[toc] | [prev] | [next] | [standalone]


#96459

FromRobert Spanjaard <spamtrap@arumes.com>
Date2016-11-13 11:25 +0100
Message-ID<o09f35$5qu$1@gioia.aioe.org>
In reply to#96451
On 13-11-16 07:30, Mr. Man-wai Chang wrote:
> On 13/11/2016 4:36 AM, Robert Spanjaard wrote:
>> #include <stdio.h>
>>
>> int main()
>> {
>>    char chewb;   /* current character being processed */
>>    int  r2d2,    /* number of numbers */
>>         c3po;    /* number of letters */
>>
>>    while ((chewb = getchar()) != EOF)
>>       if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))
>>          ++c3po;
>>       else if (chewb >= '0' && chewb <= '9')
>>          ++r2d2;
>>
>>    printf("Number of letters: %i\nNumber of numbers: %i\n", c3po, r2d2);
>>    return 0;
>> }
>
> Thanks! Need I compile this specific C program using a specific C
> compiler?  :)

Well... It's not THAT complicated. I think this is all TCPL chapter 1 stuff.
Would be surprised if there's anything calling itself a C compiler that
can't handle this. :D

-- 
Robert Spanjaard

[toc] | [prev] | [next] | [standalone]


#96462

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2016-11-13 18:47 +0800
Message-ID<o09gac$kuu$6@dont-email.me>
In reply to#96459
On 13/11/2016 6:25 PM, Robert Spanjaard wrote:
> Well... It's not THAT complicated. I think this is all TCPL chapter 1
> stuff.
> Would be surprised if there's anything calling itself a C compiler that
> can't handle this. :D

Thanks. I need to find my old Turbo C 2.0 diskette first! :)

[toc] | [prev] | [next] | [standalone]


#96452 — Re: New assignment/homework

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2016-11-13 14:32 +0800
SubjectRe: New assignment/homework
Message-ID<o091cc$662$7@dont-email.me>
In reply to#96426
On 13/11/2016 4:36 AM, Robert Spanjaard wrote:
> #include <stdio.h>
>
> int main()
> {
>    char    chewb;    /* current character being processed */
>    int    r2d2,    /* number of numbers */
>        c3po;    /* number of letters */
>
>    while ((chewb = getchar()) != EOF)
>       if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))
>          ++c3po;
>       else if (chewb >= '0' && chewb <= '9')
>          ++r2d2;
>
>    printf("Number of letters: %i\nNumber of numbers: %i\n", c3po, r2d2);
>    return 0;
> }

Modify this program to count any char[1]! :)

[toc] | [prev] | [next] | [standalone]


#96457 — Re: New assignment/homework

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-11-13 10:05 +0000
SubjectRe: New assignment/homework
Message-ID<o09dt0$d7k$1@dont-email.me>
In reply to#96452
"Mr. Man-wai Chang" <toylet.toylet@gmail.com> writes:

> On 13/11/2016 4:36 AM, Robert Spanjaard wrote:
>> #include <stdio.h>
>>
>> int main()
>> {
>>    char    chewb;    /* current character being processed */
>>    int    r2d2,    /* number of numbers */
>>        c3po;    /* number of letters */
>>
>>    while ((chewb = getchar()) != EOF)
>>       if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))
>>          ++c3po;
>>       else if (chewb >= '0' && chewb <= '9')
>>          ++r2d2;
>>
>>    printf("Number of letters: %i\nNumber of numbers: %i\n", c3po, r2d2);
>>    return 0;
>> }
>
> Modify this program to count any char[1]! :)

Why not modify it to be correct first?  I think Robert is pulling your
leg which is why, I suspect, no one has said anything so far.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#96463 — [OT]

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2016-11-13 18:47 +0800
Subject[OT]
Message-ID<o09gbt$kuu$7@dont-email.me>
In reply to#96457
On 13/11/2016 6:05 PM, Ben Bacarisse wrote:
>
> Why not modify it to be correct first?  I think Robert is pulling your
> leg which is why, I suspect, no one has said anything so far.

Let's focus on the homework first. DO you wanna show us how to modify it 
to count char[1]? :)

[toc] | [prev] | [next] | [standalone]


#96507

FromIke Naar <ike@iceland.freeshell.org>
Date2016-11-13 20:48 +0000
Message-ID<slrn3vfso2hkd9.ok2.ike@iceland.freeshell.org>
In reply to#96426
On 2016-11-12, Robert Spanjaard <spamtrap@arumes.com> wrote:
> int main()

int main(void)

> {	
>     char	chewb;	/* current character being processed */

      int chewb; /* getchar() returns an int, not a char */

>     int	r2d2,	/* number of numbers */
>     	c3po;	/* number of letters */

Note that r2d2 and c3po are not initialized.

>
>     while ((chewb = getchar()) != EOF)
>        if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))

         if (isupper(chewb) || islower(chewb))

>           ++c3po;

Incrementing an uninitialized variable.

>        else if (chewb >= '0' && chewb <= '9')

         else if (isdigit(chewb))

>           ++r2d2;

Incrementing an uninitialized variable.

>
>     printf("Number of letters: %i\nNumber of numbers: %i\n", c3po, r2d2);
>     return 0;
> }

[toc] | [prev] | [next] | [standalone]


#96509

FromRobert Spanjaard <spamtrap@arumes.com>
Date2016-11-13 22:29 +0100
Message-ID<o0am00$5dj$1@gioia.aioe.org>
In reply to#96507
On 13-11-16 21:48, Ike Naar wrote:
>>     int	r2d2,	/* number of numbers */
>>     	c3po;	/* number of letters */
>
> Note that r2d2 and c3po are not initialized.

Excuse me? C3PO and R2D2 were initialized decades ago.:)

-- 
Robert Spanjaard

[toc] | [prev] | [next] | [standalone]


#96511

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-11-13 16:38 -0500
Message-ID<b03e952f-413c-40d0-407b-0fcff410b50b@verizon.net>
In reply to#96509
On 11/13/2016 04:29 PM, Robert Spanjaard wrote:
> On 13-11-16 21:48, Ike Naar wrote:
>>>     int	r2d2,	/* number of numbers */
>>>     	c3po;	/* number of letters */
>>
>> Note that r2d2 and c3po are not initialized.
>
> Excuse me? C3PO and R2D2 were initialized decades ago.:)

True, but C is a case sensitive language, and r2d2 and c3po were not 
initialized.

[toc] | [prev] | [next] | [standalone]


#96512

FromGareth Owen <gwowen@gmail.com>
Date2016-11-13 22:24 +0000
Message-ID<87r36f587j.fsf@gmail.com>
In reply to#96511
"James R. Kuyper" <jameskuyper@verizon.net> writes:

> On 11/13/2016 04:29 PM, Robert Spanjaard wrote:
>> On 13-11-16 21:48, Ike Naar wrote:
>>>>     int	r2d2,	/* number of numbers */
>>>>     	c3po;	/* number of letters */
>>>
>>> Note that r2d2 and c3po are not initialized.
>>
>> Excuse me? C3PO and R2D2 were initialized decades ago.:)
>
> True, but C is a case sensitive language, and r2d2 and c3po were not
> initialized.

Ah.  So they're *not* the droids I was looking for.

[toc] | [prev] | [next] | [standalone]


#96510

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-11-13 16:37 -0500
Message-ID<fec36f7b-83ea-d2de-0706-dca08d26dec2@verizon.net>
In reply to#96507
On 11/13/2016 03:48 PM, Ike Naar wrote:
> On 2016-11-12, Robert Spanjaard <spamtrap@arumes.com> wrote:
...
>>     while ((chewb = getchar()) != EOF)
>>        if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))
>
>          if (isupper(chewb) || islower(chewb))

I prefer isalpha() - it's simpler, and equivalent in the "C" locale. In 
other locales, if there's a alphabetic character for which isalpha() is 
true, but islower() and isupper() are both false, I think such 
characters should be included in the letter count. 7.4.1.2p2 permits 
this, so long as icntrl(), isdigit(), ispunct() and isspace() are also 
false for such characters.

[toc] | [prev] | [next] | [standalone]


#96531

FromIke Naar <ike@iceland.freeshell.org>
Date2016-11-14 09:39 +0000
Message-ID<slrn3vfso2j1j4.6mr.ike@iceland.freeshell.org>
In reply to#96510
On 2016-11-13, James R. Kuyper <jameskuyper@verizon.net> wrote:
> On 11/13/2016 03:48 PM, Ike Naar wrote:
>> On 2016-11-12, Robert Spanjaard <spamtrap@arumes.com> wrote:
> ...
>>>     while ((chewb = getchar()) != EOF)
>>>        if ((chewb >= 'a' && chewb <= 'z') || (chewb >= 'A' && chewb <= 'Z'))
>>
>>          if (isupper(chewb) || islower(chewb))
>
> I prefer isalpha() - it's simpler, and equivalent in the "C" locale.

Rightly so.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.c


csiph-web