77 919
Assignments Done
Successfully Done
In August 2019

Answer to Question #49514 in C for faaz

Question #49514
a prgram which takes input from user & test that number is prime number using functions?
Expert's answer
#include <iostream>
#include <math.h>
#include "stdio.h"
int PrimeDetector(int user_number){
int usernumber=user_number;
int PrimeDetectorStatus=1;
if (usernumber==2) PrimeDetectorStatus=1;
if (usernumber==3) PrimeDetectorStatus=1;
int limit = round(usernumber/2);
for (int i=2;i<limit;i++)
if (usernumber%i==0) {PrimeDetectorStatus =0;break;}
return PrimeDetectorStatus;
using namespace std;
int main()
int user_number;
cout<<"Input Your number:";
if (PrimeDetector(user_number)==1) cout<<"You number is prime";
else cout<<"You number is not prime";
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions