- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Includes
Certificate & Practice Material
Programs for practice
In the program below, we've introduced beginers to programming in C
Source Code: find whether given number is prime or not
# This program finds whether given number is prime or not void main() { int n, i, flag = 0; printf("Enter a positive integer: "); scanf("%d",&n); for(i=2; i<=n/2; ++i) { // condition for nonprime number if(n%i==0) { flag=1; break; } } if (flag==0) printf("%d is a prime number.",n); else printf("%d is not a prime number.",n); }Output
Enter a positive integer: 6 6 is not a prime number