#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i, numbers[20];
srand((unsigned) time(NULL));
// set all array values to 0 because...4 the hell of it
for (i = 0; i < 20; i++)
numbers[i] = 0;
// make random numbers and print each to screen one at a time
printf("array elements are 0 to 19. total 20\n");
for (i = 0; i < 20; i++)
{
numbers[i] = rand() % 20+1;
if (numbers[i] < 10)
printf("numbers[%d] is %02d \n", i, numbers[i]);
else
printf("numbers[%d] is %d \n", i, numbers[i]);
}
return 0;
}
I am very thankful for your help! But excuse my stupidity and ignorance, how exactly is "previous +2" applied in the program codes? I'm afraid that I'm not well adjusted with the programming terms as of now since I am fairly new.
Thank you so much, it worked! If it wouldn't be too much trouble, can you help me out on the bottom reverse pyramid? For some reason it doesn't come out as a reverse pyramid as I want it to be. Would it have the same values or will the values be completely different?
Edit: Nvm finally figured it out by myself. Thank you for those who've helped!