/*program to accept n number from the user and storeall prime number in
an array and display the array*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,no,i,j,k=0;
clrscr();
printf("\nenter the rows and coloumn :");
scanf("%d",&n);
printf("\nenter the element:");
for(i=0;i<n;i++)
{
scanf("%d",&no);
j=2;
while(j<no)
{
if(no%j==0)
{
break;
}
else
j++;
}
if(j==no)
{
a[k]=no;
k++;
}
}
printf("\nthe prime numbers are:\n");
for(i=0;i<k;i++)
{
printf("%d\n",a[i]);
}
getch();
}
/*
enter the rows and coloumn :7
enter the element:3
6
4
7
5
13
31
the prime numbers are:
3
7
5
13
31
*/
No comments:
Post a Comment