048. Write a program to accept a number from user and print if it is prime or not in C language

#include<conio.h>
#include<process.h>
main()
{
	int i,n;
	clrscr();
	printf("Enter number...");
	scanf("%d",&n);
	for(i=2;i<=n/2;i++)
	{
		if(n%i==0)
		{
		printf("Not Prime");
		getch();
		exit(0);
		}
	}
	printf("Prime ");
	getch();
}

4 thoughts on “048. Write a program to accept a number from user and print if it is prime or not in C language

Leave a Reply

Your email address will not be published. Required fields are marked *