Login to ask a question from Recursive program in c

C Program to Find whether a Number is Prime or Not using Recursion

This is a C program to find whether a number is prime or not using recursion.

Problem Description

The following C program, using recursion, finds whether the entered number is a prime number or not.

Problem Solution

A prime number is an integer that has no integral factor but itself and 1.

Program/Source Code

#include

 

int primeno(int, int);

 

int main()

{

    int num, check;

    printf("Enter a number: ");

    scanf("%d", &num);

    check = primeno(num, num / 2);

    if (check == 1)

    {

        printf("%d is a prime number\n", num);

    }

    else

    {

        printf("%d is not a prime number\n", num);

    }

    return 0;

}

 

int prime.... Show More

Previous Question Next Question
🔗

Similar Questions

From Recursive program in c · C programming

View All
WhatsApp