adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

C Program to check whether a number is Prime or Not

C Program to check whether a number is Prime or Not

#include<stdio.h>
 int main(){
 	
 	int n, i, flag;
 	printf("Enter a number :- ");
 	scanf("%d", &n);
 	
 	i = 2;
 	flag = 0;
 	while(i <= n / 2){
 		if(n % i == 0){
 			flag = 1;
 			break;
		 }
		i++;
	}
	if(flag == 1)
	   printf("%d is not a prime number.", n);
	else
	   printf("%d is a prime number.", n);
	 
 	return 0;
 }

Output :-











Video 



Post a Comment

0 Comments