A program to print the prime numbers less than or equal to the number using function.
A program to print the prime numbers less than or equal to the number using function.
Codes
/*A program to print the prime number until ‘n’ using function*/
/*Programed by Jitendra Kr Yadav
10116
22 Mar,2011*/
#include<stdio.h>
#include<conio.h>
int prime(int);
main()
{
int n;
printf(“Enter the value: “);
scanf(“%d”,&n);
prime(n);
getch();
}
int prime(int x)
{
int a,i;
for(a=1;a<=x;a++)
{
i=2;
while(i<a)
{
if(a%i==0)
break;
i++;
}
if(a==i)
printf(“%d\t”,a);
}
printf(“\n\nPress any key to continue…”);
}
Output
Enter the value: 15
2 3 5 7 11 13
Press any key to continue…