my code stock.com

primos

Snippet options

Download: Download snippet as programa-22.c.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

#include<stdio.h>
#include <conio.h>
int x[100], n=20, i=3;
int j, count, c, aux;
int main()
{
	printf("\nPrograma: Almacena los primeros 20 numero primos \nDiana 1670991");
	if (n>=1)
	{
    	printf("\n\tLos primeros %d numeros primos son:\n", n);
    	printf("\n");
	}
	for (count=2;count<=n;)
	{
    	for (c=2;c<=i-1;c++)
		{
        	if (i%c==0)
        	break;
      	}
      	if (c==i)
    	{
        	printf("%d\n",i);
        	count++;
        	x[i]=i;
		}
		i++;
	}
   return 0;
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.