FIFA-2022 Career Guide Free Tutorials Go to Your University Placement Preparation 
0 like 0 dislike
469 views

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.1k points)
edited by
 
Best answer

Prime Number Evaluation Using Function

In this program we are going to evaluate if a number is prime number or not using functions in C programming.

To learn basics of function in C programming Click Here.

Example :

#include<stdio.h>
#include<conio.h>

//Declaration of prime funtion
int prime(int x);

void main()
{
int x;
clrscr();

//Taking number from the user to check if it's prime or not
printf("\nEnter a number:");
scanf("%d",&x);

//calling prime number for true of false
if(prime(x))
printf("\nNumber is Prime");
else
printf("\nNumber is not prime");
getch();
}

//Definition of prime function
int prime(int n)
{
int checkprime=0,i;
for(i=2;i<n;i++)
{
if(n%i==0)
checkprime=1;
}
if(checkprime==0)
return 1;
else
return 0;
}

Output :

Output of above program showing prime number


For More GTU C Programming Lab Experiments Click Here

Learn & Improve In-Demand Data Skills Online in this Summer With  These High Quality Courses[Recommended by GOEDUHUB]:-

Best Data Science Online Courses[Lists] on:-

Claim your 10 Days FREE Trial for Pluralsight.

Best Data Science Courses on Datacamp
Best Data Science Courses on Coursera
Best Data Science Courses on Udemy
Best Data Science Courses on Pluralsight
Best Data Science Courses & Microdegrees on Udacity
Best Artificial Intelligence[AI] Courses on Coursera
Best Machine Learning[ML] Courses on Coursera
Best Python Programming Courses on Coursera
Best Artificial Intelligence[AI] Courses on Udemy
Best Python Programming Courses on Udemy

Related questions

 Important Lists:

Important Lists, Exams & Cutoffs Exams after Graduation PSUs

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy ||  Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 

 

Free Online Directory

...