Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void main()
- {
- int num, i, flag;
- printf("This is a simple program to check Prime Number.\n\n");
- printf("Enter the number to check : ");
- scanf("%d", &num);
- flag = 0;
- if(num <= 1)
- {
- flag = 1;
- }
- for(i = 2; i <= num / 2; i++)
- {
- if(num % i == 0)
- {
- flag = 1;
- break;
- }
- }
- if(flag == 0)
- {
- printf("%d - is a Prime Number.", num);
- }
- else
- {
- printf("%d - is not a Prime Number.", num);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement