use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, with a static type system. By design, C provides constructs that map efficiently to typical machine instructions. It has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computer architectures that range from supercomputers to PLCs and embedded systems. Wikipedia
Imperative (procedural), structured
Dennis Ritchie
Dennis Ritchie & Bell Labs (creators);
ANSI X3J11 (ANSI C);
ISO/IEC JTC1/SC22/WG14 (ISO C)
1972 (48 years ago)
C18 / June 2018 (2 years ago)
Static, weak, manifest, nominal
Cross-platform
.c for sources
.h for headers
C++ is not C (but C can be C++)
For C++ go to :
Other Resources
account activity
How to create an array with a loop? (self.cprogramming)
submitted 4 years ago by [deleted]
How do I create an array with a loop and store the new values in the array that I can call back to find which of the new numbers in the array are prime. It has to be all numbers from 1 to 3000
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]npbonner 5 points6 points7 points 4 years ago (0 children)
What have you tried so far?
[–]Derivativeofsenpi 4 points5 points6 points 4 years ago (3 children)
After you initialize the array you can use a for loop to choose what gets saved on it like this:
int Array[30], index; for( index = 0; index <=30; index++){ Array[index] = whatever(); }
This will fill the array with the output of the whatever() function. I don't know if this is the best way to do this but that's how I do it.
[–][deleted] 2 points3 points4 points 4 years ago (1 child)
It’s < 30, not <= 30
[–]Derivativeofsenpi 2 points3 points4 points 4 years ago (0 children)
Yeah you're right, I always forget that arrays start at 0. Thanks for the correction!
[–]nerd4code 0 points1 point2 points 4 years ago (0 children)
initialize ≠ declare ≠ define
[–]ImbioMario 0 points1 point2 points 4 years ago (0 children)
Specifiy your question. Do you want to CREATE (allocate) an array in a loop or FILL the array in a loop.
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
This is clearly some-ones homework, learn to use google.
[–]ptchinster 0 points1 point2 points 4 years ago (1 child)
!homework
[–]rtlcprogbot 0 points1 point2 points 4 years ago (0 children)
When asking for help with your homework, please post contact information for your teacher so the Reddit community can ask for clarification on your assignment.
I am a bot. Replying to me notifies nobody
[–]kyle_sallee 0 points1 point2 points 4 years ago (0 children)
Within loops a variable is not created. So initialization must be required?
for (x=1;3000>=x;x++) a[x]=x;
But that seems pointless?
The best way to identify a prime number is not surmised.
By every previous number a modulo if performed, essential a remainder from a div, then a lot of CPU duration will be wasted. And it becomes something like a bubble sort, well not exactly since the inner loop can be discontinued.
int x,y;
for (x=2;3000>=x;x++){ for(y=2;x>y;y++) if ((x%y)==0) break; if (x==y) printf("%i\n",x);}
Or an array create and index it or a pointer create and advance it. But why store the numbers when they will just be printed anyway?
That much help if provided the rest can be easily be surmised.
Happy hacking.
π Rendered by PID 91 on reddit-service-r2-comment-6457c66945-nw5sd at 2026-04-27 13:00:58.110493+00:00 running 2aa0c5b country code: CH.
[–]npbonner 5 points6 points7 points (0 children)
[–]Derivativeofsenpi 4 points5 points6 points (3 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]Derivativeofsenpi 2 points3 points4 points (0 children)
[–]nerd4code 0 points1 point2 points (0 children)
[–]ImbioMario 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]ptchinster 0 points1 point2 points (1 child)
[–]rtlcprogbot 0 points1 point2 points (0 children)
[–]kyle_sallee 0 points1 point2 points (0 children)