C Programming Tutorial 57, Generating Random Numbers

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

11 years later, a lot of Adam's work here is still relevant. It's a great help in a software dev't program I'm in. Asante sana

wiings
Автор

Wow, amazing C programming tutorial set!!! Thank you very much for putting in the effort, I truly appreciate it. I just wanted to give you a shout out and say thanks, it's the least I can do. A truly incredible job.

Thanks again!

saichelx
Автор

The / operator just does straight up division, so 10 / 2 = 5. The % operator performs the modulus operation. So it divides the numbers, but gives you back the remainder. So 10 % 2 = 0 because 2 goes into 10 evenly so there would be a remainder. 11 % 2 would give us 1 since 2 does not go into 11 evenly, there's 1 left over.

iTzAdamX
Автор

Thanks, this REALLY helped and youre also amazing at explaining!

gs
Автор

Why are there no cutely brackets around the printf function after the for loop?

bsaxon
Автор

Great explanation man. Thank you so much.

BluemoeNYJ
Автор

Hi Adam, why cant u put the srand into the for loop?

ljk
Автор

The same here:
'for' loop initial declarations are only allowed in C99 mode use option -std=c99 or -std=gnu99 to compile your code, if I can make it work I'll tell you.

Elec-DIY
Автор

Is it possible to make void variables(possibly that store NULL or something)?

sonickk
Автор

how do you eliminate duplicate numbers being
generated??

iestyngrills
Автор

Thank you very much for the explanation!

RamonBlanquer
Автор

Wait Wait!!! confused how is you use % for dividing and not the / sign with %?

thewhisperinyourears
Автор

function 'main':|
'for' loop initial declarations are only allowed in C99 mode|
use option -std=c99 or -std=gnu99 to compile your code|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 4 seconds) ===|

I get this when compiling and running.

alexp
Автор

I want that random number just show only from 1->10... Tell me how.. Thanks

sambovisal
Автор

do this if you get the "c99 whatever" error:
int main()
{
int i;
for (i = 0; i < 10; i++)
printf("%i\n", rand());
return 0;
}

Nettaphone
Автор

Why are there no curly brackets around the printf function after the for loop? 

bsaxon