1a.Program in C for obtaining prime numbers up to a given number*/
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
int count[100];
printf("enter the range between 1 and 100 to print the prime numbers");
scan("%d",&n);
for(i=1;i<=n;i++)
for(j=1;j<=i;j++)
if(i%j==0)
count[i]=count[i]+1;
printf("The prime numbers are");
for(i=1;i<=n;i++)
if(count[i]==2)
printf(" %d",a[i]);
}
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
int count[100];
printf("enter the range between 1 and 100 to print the prime numbers");
scan("%d",&n);
for(i=1;i<=n;i++)
for(j=1;j<=i;j++)
if(i%j==0)
count[i]=count[i]+1;
printf("The prime numbers are");
for(i=1;i<=n;i++)
if(count[i]==2)
printf(" %d",a[i]);
}
No comments:
Post a Comment