Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Can anyone tell me the errors in my code(C++). It will not compile.?

Update:

#include<iostream>

using std::cout;

using std::cin;

using std::endl;

#include<cmath>

#include<string>

int main() {

int n=0;

std::cin>>n>> std::endl;

while(std::cin>>n>>) {

if(n<2) {

std::cout<<"1"<<std::endl;

}

else {

for(int m=2;m<= sqrt(n); m++)

{

if(n%m!=0) {

std::cout<<"1"<<std::endl;

}

}

}

}return 0;}

1 Answer

Relevance
  • Nick
    Lv 6
    6 years ago

    Not without seeing it, no. That said, have you tried running it through lint? That might point out your error for you or it could be as simple as a missing semicolon.

    What line number is the error on? Have you checked the previous line or two to see if there's an error?

Still have questions? Get your answers by asking now.