jituTechnology

jituTechnology

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…

No comments yet.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

May 2024
S M T W T F S
 1234
567891011
12131415161718
19202122232425
262728293031