Showing posts with label prime. Show all posts
Showing posts with label prime. Show all posts

Saturday, March 10, 2012

Write a C program to find prime numbers from 1 to n.

#include
#include
void main()
{
int i,j,n;
clrscr();
printf("Enter the no: ");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{
for(j=2;j<=i-1;j++)
{
if(i%j==0)
break;
}
if(j==i)
printf("%d ",j);
}
getch();
}

Tuesday, February 22, 2011

Write a Visual Basic Program for displaying all prime numbers below 10000

WAP for displaying all prime numbers .
______________________________________

Dim a

Private Sub clear_cmd_Click()
List1.Clear

End Sub

Private Sub exit_cmd_Click()
End
End Sub

Private Sub Form_Load()

End Sub

Private Sub generate_cmd_Click()
List1.Clear
a = Val(Text1.Text)
For i = 2 To a Step 1
For j = 2 To i Step 1
If i Mod j = 0 Then
GoTo S
ElseIf j + 1 = i Then
a = i
List1.AddItem (a)
End If
Next j
S:
Next i




End Sub


_______________________________________
OUTPUT
_______________________________________


____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image