Name: Anonymous 2012-06-16 15:53
so I just started programing like two days ago (c++) , and Im doing basic exercises, nothing really complicated, but for some reason I cant get this, any help is welcome
Pd: I have never been so scared of posting in a board
---------------------------------------
#include <iostream>
using namespace std;
int main()
{
int n;
int c;
int crash;
cout<<"Insert a number"<<endl;
cin>>n;
/*do{
if(n%c==0){
crash = 1;
}
c = c - 1;
}while(c == 1);*/
for(c = n-1; c == 1; c--){
if(n%c == 0){
crash = 1;
}
}
if(crash == 1){
cout<<"The number is prime"<<endl;
} else{
cout<<"The number is not prime"<<endl;}
return 0;
}
Pd: I have never been so scared of posting in a board
---------------------------------------
#include <iostream>
using namespace std;
int main()
{
int n;
int c;
int crash;
cout<<"Insert a number"<<endl;
cin>>n;
/*do{
if(n%c==0){
crash = 1;
}
c = c - 1;
}while(c == 1);*/
for(c = n-1; c == 1; c--){
if(n%c == 0){
crash = 1;
}
}
if(crash == 1){
cout<<"The number is prime"<<endl;
} else{
cout<<"The number is not prime"<<endl;}
return 0;
}