program

P

paul

colud someone please post up a c program to do this

Write a program that counts the number of times the first three
letters of the alphabet (a, b, c, and A, B, C) occur in a file. Do not
distinguish between lowercase and uppercase letters.
 
P

pete

paul said:
colud someone please post up a c program to do this

Write a program that counts the number of times the first three
letters of the alphabet (a, b, c, and A, B, C) occur in a file. Do not
distinguish between lowercase and uppercase letters.

I would put the counters in a switch and let the lower cases
fall through to the upper cases.
 
X

xarax

pete said:
I would put the counters in a switch and let the lower cases
fall through to the upper cases.

He is not asking how to do it. He asking for
someone else to do it for him, so he can get
a good grade on his homework.
 
T

Tristan Miller

Greetings.

colud someone please post up a c program to do this

Write a program that counts the number of times the first three
letters of the alphabet (a, b, c, and A, B, C) occur in a file. Do not
distinguish between lowercase and uppercase letters.

#include <stdio.h>

/* Prints the number of times 'a', 'b', 'c', 'A', 'B', and 'C'
occur in "a file". */

int main(void) {
printf("1\n");
return 0;
}
 
B

Bruno Desthuilliers

paul said:
colud someone please post up a c program to do this

Write a program that counts the number of times the first three
letters of the alphabet (a, b, c, and A, B, C) occur in a file. Do not
distinguish between lowercase and uppercase letters.

<business-as-usual>
The good news is that most people here are able to write this program.
The bad news is that none of them are willing to do your homework.

Write the program, post it, and perhaps some one may help you correcting it.
</business-as-usual>

Bruno
 
C

CBFalconer

paul said:
colud someone please post up a c program to do this

Write a program that counts the number of times the first three
letters of the alphabet (a, b, c, and A, B, C) occur in a file.
Do not distinguish between lowercase and uppercase letters.

Sure, glad to. I'll start as soon as I receive your certified
check for $200 (US) (1 hours work minimum consulting charge). For
no additional fee I will also be glad to forward the result
directly to your instructor.
 
T

Tom St Denis

CBFalconer said:
Sure, glad to. I'll start as soon as I receive your certified
check for $200 (US) (1 hours work minimum consulting charge). For
no additional fee I will also be glad to forward the result
directly to your instructor.

You get 200$/h? Wow, so that's how a greedy SOB works...

Tom
 
D

Don Porges

CBFalconer said:
Sure, glad to. I'll start as soon as I receive your certified
check for $200 (US) (1 hours work minimum consulting charge). For
no additional fee I will also be glad to forward the result
directly to your instructor.

Given that he gives his email address as (e-mail address removed), I bet
it would be pretty easy to do that right now.

(No, I'm not suggesting anyone do that; I'm warning "paul" that he's not very
stealthy and shouldn't try to be.)
 
D

Don Porges

CBFalconer said:
Sure, glad to. I'll start as soon as I receive your certified
check for $200 (US) (1 hours work minimum consulting charge). For
no additional fee I will also be glad to forward the result
directly to your instructor.

Given that he gives his email address as (e-mail address removed), I bet
it would be pretty easy to do that right now.

(No, I'm not suggesting anyone do that; I'm warning "paul" that he's not very
stealthy and shouldn't try to be.)
 
B

Buck Rogers

colud someone please post up a c program to do this

Write a program that counts the number of times the first three
letters of the alphabet (a, b, c, and A, B, C) occur in a file. Do not
distinguish between lowercase and uppercase letters.

I am not going to post the answer for you, but this sure is a good
exercise for a beginner like me! Time to get out the pen and paper!
Thanks for getting me interested in this problem!

Buck
 
R

Richard Heathfield

Joona said:
What, would you do it for only $199.99 per hour then? =)

If we adopt the conventions that we only ever bid *up* for homework
questions and that subsequent bids always supersede existing bids until a
bid is finally accepted by the OP, perhaps we can distribute a few more
cluons into the newbie community.

My bid is $250.
 
J

Joona I Palaste

If we adopt the conventions that we only ever bid *up* for homework
questions and that subsequent bids always supersede existing bids until a
bid is finally accepted by the OP, perhaps we can distribute a few more
cluons into the newbie community.
My bid is $250.

OK, I bid $300.

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"When a man talks dirty to a woman, that's sexual harassment. When a woman talks
dirty to a man, that's 14.99 per minute + local telephone charges!"
- Ruben Stiller
 
A

Alexander Bartolich

begin followup to Joona I Palaste:
OK, I bid $300.

Cool.
So the financial damage of this piece of code is $50 per line.
OTOH I have some doubts whether the OP can compile, run, format,
present and explain it.

#include <limits.h>
#include <stdio.h>
#include <ctype.h>
int main(){int c;int n[1<<CHAR_BIT]={0};while(EOF!=(c=getchar()))
n[tolower(c)]++;printf("a=%d b=%d c=%d\n",n['a'],n['b'],n['c']);
return 0;}
 
J

Joona I Palaste

Alexander Bartolich said:
begin followup to Joona I Palaste:
Cool.
So the financial damage of this piece of code is $50 per line.
OTOH I have some doubts whether the OP can compile, run, format,
present and explain it.
#include <limits.h>
#include <stdio.h>
#include <ctype.h>
int main(){int c;int n[1<<CHAR_BIT]={0};while(EOF!=(c=getchar()))
n[tolower(c)]++;printf("a=%d b=%d c=%d\n",n['a'],n['b'],n['c']);
return 0;}

Here's my version. 254 characters.

#include <stdio.h>
#include <ctype.h>
int a[3]={0};int count(void){int c=getchar();return c==EOF?0:((tolower(c)=='a'?
a[0]++:tolower(c)=='b'?a[1]++:tolower(c)=='c'?a[2]++:0),count());}int
main(void){return count(),printf("%d %d %d\n",a[0],a[1],a[2]),0;}
 
B

Ben Pfaff

Joona I Palaste said:
Alexander Bartolich said:
begin followup to Joona I Palaste:
Cool.
So the financial damage of this piece of code is $50 per line.
OTOH I have some doubts whether the OP can compile, run, format,
present and explain it.
#include <limits.h>
#include <stdio.h>
#include <ctype.h>
int main(){int c;int n[1<<CHAR_BIT]={0};while(EOF!=(c=getchar()))
n[tolower(c)]++;printf("a=%d b=%d c=%d\n",n['a'],n['b'],n['c']);
return 0;}

Here's my version. 254 characters.

#include <stdio.h>
#include <ctype.h>
int a[3]={0};int count(void){int c=getchar();return c==EOF?0:((tolower(c)=='a'?
a[0]++:tolower(c)=='b'?a[1]++:tolower(c)=='c'?a[2]++:0),count());}int
main(void){return count(),printf("%d %d %d\n",a[0],a[1],a[2]),0;}

My entry (184 characters):

int main(){int getchar(),printf(const char*,...),tolower();int c,n[4]={0};while
((c=tolower(getchar()))>=0)n[c=='a'?0:c=='b'?1:c=='c'?2:3]++;printf("a=%d,b=%d\
,c=%d\n",*n,n[1],n[2]);}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top