PPS Practical 24
- Aim: Write a program to check whether the given number is prime or not.
- Code:
//For turbo C++ remove below comments #include <stdio.h> //#include<conio.h> void main() { int n,i,c=2; printf("Enter number : "); scanf("%d",&n); for (i = 2; i <= n/2; i++){ if (n%i==0){ c++; } } if (c==2){ printf("%d is a prime number",n); }else{ printf("%d is not a prime number",n); } // getch(); }
- Output:

Comments
Post a Comment