Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 12-07-2005
nicoleha
Question:

Write a program to show the operation of the random number generator.
The program will generate a specified number of random numbers in a given range.
It will count the number of times each number occurs.
It will display on the screen how many times each number occurred, in the form:
0 occurred 100 times
1 occurred 102 times
2 occurred 98 times
etc.
It will calculate the minimum number of occurrences, the maximum number of occurrences and the number of times each number could be expected.
e.g.
Minimum count =98, maximum count =102, expected count =100.
Use date_time_seed() and rand() (see example program below)
The prpgram will accept the following single keystroke commands from the keyboard ..
• ‘R’ to run the program, prompting for the number range and the number of numbers to generate. After running it prompts for either R or Q again.
• ‘Q’ to quit the program.

Code:

```#include <stdlib.h> #include <stdio.h> #include <DBOS\LIB.h> #include <CLIB.H> void count_nums(int *a, int range, int num); int my_rand(int); int get_max(int *a, int s); int get_min(int *a, int s); int main(void) {     int range, num;     /*!! foo.c:14: warning: implicit declaration of function ‘date_time_seed’ */     date_time_seed();     /*!! foo.c:15: warning: ISO C90 forbids mixed declarations and code */     int a[50], t[50];     char c;     int s, i;     printf(" * Please press r/R to run or press q/Q to exit *\n");     /*!! foo.c:20: warning: implicit declaration of function ‘getch’ */     c = getch();     /*run by pressing r and exit by pressing q */     if (c == 'r' || c == 'R') { /*accept both lower and upper case */         /*move to next statment only if the input in range 1 to 20 */         do {             printf("Enter the range size(max=20)");             scanf("%d", &range);         }         while (range < 0 || range > 20);         printf("How many numbers do you wish to generate?");         scanf("%d", &num);         date_time_seed;         count_nums(a, range, num);         for (i = 0; i < range; i++)             printf("%d:%d\n", i, t[i]);         printf("Maximum count:%d\n", get_max(a, range));                 printf("Minimum count:%d\n", get_min(a, range));         printf("Expected: %d\n", (int) (num / range));     }     if (c == 'q' || c == 'Q')         exit(1);     return (0); } int my_rand(int range) {     int r;     date_time_seed();     r = 1 + rand() % range;     return r; } void count_nums(int *a, int range, int num) {     int i;         int t[50];     for (i = 0; i <= num; i++)     {         a[i] = my_rand(range);         t[i] = 0;         t[a[i]]= t[a[i]]+1;           printf("%d", a[i]);     }     } /* function to find the max */ int get_max(int *a, int s) {     int i, max;   max= *a;     for (i = 0; i < s; i++)         if (*(a + i) > max)             max = *(a + i);     return (max); } /*function to find the min */ int get_min(int *a, int s) {     int i, min;     min = *a;     for (i = 0; i < s; i++)         if (*(a + i) < min)             min = *(a + i);     return (min); }```
• 12-07-2005
quzah
1 - Stop making new threads for this same old topic.
2 - "I don't seem to compile it." So, what in fact happens? I suspect some form of, oh, I don't know, error message appears. That'd be helpful.
3 - Why should I spend the time to copy/paste your text into an editor and then try to compile it, just because you're too lazy to tell me the error you get?
4 - Why should I spend the time to copy/paste your text into an editor, get it to compile, and then spend the time running tests on it, just because you won't tell us what it does/doesn't do correctly?
5 - How to ask questions the smart way.

Quzah.
• 12-07-2005
nicoleha
Sorry
Quzah,
Sorry but thanks for correcting me.
Ive found some eeror in my program while compiling it. I hence have rewrite this part of the program.
When i run it, ive got this result...
0: 1
1:1
2:1
....
basically, everything is : 1. I dunno where is the mistake. can u please guide me?

Thanks.

Code:

```int my_rand(int range) {     int r;       date_time_seed();         r = 1 + rand() % range;         return r; } void count_nums(int *a, int range, int num) {     int i, r;     for (i = 0; i <= num; i++)     {    range= my_rand(range);           a[i]= 0;           //r= my_rand(range);         a[i]= a[i]+ 1;           } }```
• 12-07-2005
quzah
Code:

```void count_nums(int *a, int range, int num) {     int i, r;     for (i = 0; i <= num; i++)     {    range= my_rand(range);           a[i]= 0; /* Set this spot to zero. */           //r= my_rand(range);         a[i]= a[i]+ 1; /* Now set this spot to one. */           } }```
Quzah.
• 12-07-2005
jsbeckton
He will be rude to you because, you need help, and so you can't say anything. Most of the people in these forums are helpful, I wouldn't have made it through CIT without the help that I got here, I am truly grateful for it.

Why couldn't he have just said, "Hey, can you give me your errors so I can see what the problem is", but instead he decides to list all of the things you did wrong and then procedes to post a link "How to ask questions the smart way", a sly way to call you dumb. I guess 6,000+ posts gives this guy the right to be a tool.
• 12-07-2005
quzah
I don't feel the need to be sly about calling someone dumb. I just come right out and say it. Did you even read the link? I suspect not. If you had, you'd find it is actually a good read. If people actually learn to ask questions as described in the link, they're better off for it. Seriously, what's better:

"my pr0grm dnt wrk"

Or...

"I'm trying to compile this program, and it gives me the following error..."
"I'm trying to run this program, and it's not giving the output I expect. I input ____ and should get ____, but instead I get ___."

Yeah, you're right. No one should learn how to ask questions the smart way. It's so much better for everyone involved if questions are worded horribly, or better yet, are simply a text dump of code, with no question at all!

On an aside, listing what is wrong is a fine way to teach. You must be one of those idiots who doesn't want to know what's wrong, and just want's someone to write their stuff for them. See, I have no need to be sly. You're a moron. You came in here to contribute nothing at all to this thread, other than your pathetic attempt of trolling.

I on the other hand:
1 - Pointed out where the OP was at fault.
2 - Showed them a better way to ask for help, which incidently, they used in their second post.
3 - Showed them why they were getting the output they described; you know, due to me showing them a better way to ask questions.
4 - Made some fine lists, which will no doubt continue to irk you.
5 - You're dumb. See, no slyness about it. Actually, it is. There are layers upon layers of joke here that you'll never grasp.

Quzah.
• 12-07-2005
jsbeckton
I may not be a genius but I know that:

1) "On an aside, listing what is wrong is a fine way to teach" Makes no sense whatsoever.

2) "See, no slyness about it" makes no sence..

3) In your signature, for the second time, ass hole, is spelled @\$\$hole!

4) I'm just telling you what she would if she didn't need your help Einstein!

5) Perhaps you should take a break from insulting "newbies" and learn a little respect. Sorry, no link for that, your parents obviously forgot to teach you that.
• 12-07-2005
major_small
will you please just shut the fvck up and sit the fvck down?

quzah has more respect on these here boards than you will probably ever have, and it's because of stuff like this. While he may be a little gruff in his approach, it works. It weeds out the leeches that just come here and weigh down the entire community, and hardens those that will be around for a while.

Most of us think quzah is the perfect answer to the new people that walk in with their heads up their arsses.

edit: oh yeah, I guess now you see why he spelled it the way he did... it's called a SWEAR FILTER. jackass.
edit2: "I'm just telling you what she would if she didn't need your help Einstein!"
Were you trying to convery a complete thought? Those happen in sentences. what you posted there was a setence fragment, which, as it's name suggests, is a fragment of a sentence. Therefore, only a fragment of your thought came across.
• 12-07-2005
quzah
"On an aside" does in fact make sense, if you have basic comprehension of the English language. Here, go read a dictionary, and understand the meaning of the word aside as it was used.

# A parenthetical departure; a digression.

Do you understand what a digression is? It's an aside. That is to say, it isn't the main topic, it's, well if you can't understand, you shouldn't try to be a smart ass.

"No slyness about it" means that I wasn't being sly. See, there was no slyness in that remark. Hense the phrase "no slyness about it". Slyness is the act of being sly. Being sly means to be cunning. Thus, the phrase "no slyness about it" translates to "See, I wasn't being cunning there...". Cunning, if you don't know the meaning of the word, means deceptive, cute, witty, etc. None of these qualities you seem to posess, so I can understand your lack of comprehension; having no real world experience in being clever yourself.

Actually, the hole of an ass, would in fact be an "ass hole". Just like the hole left by a bullet is a "bullet hole". You don't say "bullethole", that would just be wrong. Bullet hole. Ass hole.

Quote:

"4) I'm just telling you what she would if she didn't need your help Einstein!"
People who can't form complete sentences should avoid debates on topics such as sentence structure and reading comprehension.

Finally, we'll close with this thought: Why on earth would I care if I have your respect? Oh, that's right. I don't. See, you mean nothing to me. Your respect, or lack there of, also means nothing to me. You aren't even a pinpoint of light in the night sky of my life. Have a nice day.

Quzah.
• 12-07-2005
jsbeckton
The way I look at it is you should be just as polite in a forum as you would if you were talking directly to someone, sure you can be blunt but there is no need to be rude. I bet he wouldn't say half of these things if someone were there to put him in his place.

If you can't figure out what it means, then ask quzah to help you. However, I sugest that you read his link on "how to ask questions the smart way" first you freaking idiot.

By the way, on an aside does not make sence. You can talk about english all day but you know that it dosen't make sence.
• 12-07-2005
quzah
Quote:

Originally Posted by jsbeckton
The way I look at it is you should be just as polite in a forum as you would if you were talking directly to someone, sure you can be blunt but there is no need to be rude. I bet he wouldn't say half of these things if someone were there to put him in his place.

So your real problem is that you expect everyone to be polite to you in person. What on earth ever gave you that idea? What sheltered corner of the globe do you live in? One without people apparently. Welcome to the real world.

Quzah.
• 12-07-2005
jsbeckton
Don't you have a job or something? Shouldn't you be mopping up the floors in the "happy booths" at the adult bookstore?
• 12-07-2005
quzah
Quote:

Originally Posted by jsbeckton
Don't you have a job or something?

Here ends your ability to hold a meaningful conversation. See right here you might as well blow your own head off. My posting apparently means that I have no job or life, while your posting means, what? That somehow you're employed with a great life.

You see, this is what's called being hypocritical. It means saying one thing and doing another. I figured I'd save you the trouble of replying with some would-be sentence crying that you don't know the meaning of the word 'hypocritical'. Or that because you haven't heard it used in a sentence that way, it's not a valid use of the word.

On an aside, Google has around 26,000 uses of the phrase "on an aside". See, that's how you use the phrase "on an aside" in correct form and context.

Quzah.
• 12-07-2005
jsbeckton
Great, 26,000 other Idiots I may come across! Life is tough! I'm a student, you are the creepy old guy at the high school football games that no one knows, has no sons on the team, just likes to "hang out with the kids". You would never think of taking like that to someone in person because you don't like to get slapped in from of the kids. Get a life you freak.
• 12-07-2005
CornedBee
I never heard of anything making "sence", actually. If you're lucky, you might make sense, though. I don't think you do.

(It should be mentioned, though, that the far more common phrase is "as an aside".)
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last