WRITE A C PROGRAM TO ACCEPT A NUMBER AND FINDOUT WHETHER IT IS PRIME OR NOT.
Share
WRITE A C PROGRAM TO ACCEPT A NUMBER AND FINDOUT WHETHER IT IS PRIME OR NOT.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
The program output is also shown below.
* C program to check whether a given number is prime or not.
* and output the given number with suitable message.
#include <stdlib.h>
int num, j, flag;
printf("Enter a number \n");
scanf("%d", &num);
if (num <= 1)
printf("%d is not a prime numbers \n", num);..
Explanation:
Proof: The definition of a prime number is a positive integer that has exactly two positive divisors. However, 1 only has one positive divisor (1 itself), so it is not prime. ... A prime number is a positive integer whose positive divisors are exactly 1 and itself.