I am having trouble with my C++ code I can\'t get it to compile command prompt s
ID: 3532056 • Letter: I
Question
I am having trouble with my C++ code I can't get it to compile command prompt says
there's an error in the intmain() funtion but I cant figure out what Im doing wrong.
Thanks !
This is my problem Write a void function that uses two nested for loops and the modulus(%) operator to detect and print to a specified output file, the first n prime integers.
#include <iostream> using namespace std; void primeGen(int n, ofstream& file); int main() { int i,j,n; bool prime; cout << "Prime Numbers between 1 and " << n << endl; { { for (i=1;i<=n;i++) prime=true; } for (j=2;j<i;j++) { if (!(i%j)) prime=false; } } if (prime) cout << i << endl; system("pause"); return 0; }
Explanation / Answer
after the statement cout <<'' primenumbers between 1 and........
there is an unneccesary token '{'
and the nagain same token '{' should be placed after the statement for(i=1;i<=n;i++)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.