Write a C Program to check whether the number is prime or not ?
In our last program, we saw how to calculate profit and loss in c programming. In this program, we will use an if-else statement to check whether the number is prime or not.
A prime number is a positive integer which is divisible only by 1 and itself. For example: 2, 3, 5, 7, 11, 13.When a number has more than two factors then it is called a composite number.
This program takes the number from the user and then checks whether the input number is prime or not. Then the program displays the result.
C programming code:
int prime(int num)
printf(“%d num is prime\n”,num);
printf(“%d num is not prime\n”,num);
printf(“enter the value of a”);
Let us know if you are stuck somewhere and need help.We will try our best to provide you a solution to your problem. You are also free to request some other problem using our comments section.