Write a program to check that the given number is prime or not. | CODE WITH SHARAD

Write a program to check that the given number is prime or not.

Written by Sharad Raj on 13th of March, 2018

BASIC PROGRAMS   C LANGUAGE PROGRAMS

PROGRAM CODE

#include<stdio.h>

#include<conio.h>

void main()

{

int number,x;

clrscr();

printf("Enter the number : ");

scanf("%d",&number);

for(x=2;x<=number-1;x++)

{

if(number%x==0)

{

printf("\n %d is not a prime number.",number);

break;

}

}

if(x==number)

printf("\n %d is a prime number.",number);

getch();

}


Comments


Contact