Hi,
I want to write a code which defines whether a number is prime or not. Also, ask me if I want to continue for entering next number. Below is my code. I run my program, but it is clear that there are some problems that I cannot find them.
#include "stdafx.h"
#include <iostream>
using namespace std;
void T (int);
int main()
{
int x;
char ch;
while(true){
cout<<'x=';
cin>>x;
T(x);
cout<<"do you have desire to continue(y/else)";
cin>>ch;
if(ch!='y')
break;
}
cin.get();
cin.get();
}
void T (int x){
int i;
for(i=1;i<=(x/2);i++){
if(x%i==0)
cout<<"no prime";
else
cout<<"prime";}
}
Please help me in this regard. What is the mistake?
Many Thanks,