i tried doing the foll c++ program
to print the divisors of a given number n given by the user
int i,n,;
cout%26lt;%26lt;"enter the number";
cin%26gt;%26gt;n;
for(i=1;i%26lt;=n;i++)
{
if(i%n==0)
cout%26lt;%26lt;i;
}
getch();
}
thanks a ton for telling wats my mistake
tutu
Tell me what's wrong with c++ program?
int i,n,; //There is an extra "," before the semicolon
cout%26lt;%26lt;"enter the number";
cin%26gt;%26gt;n;
for(i=1;i%26lt;=n;i++)
{
if(i%n==0) //This should be n%i not i%n careless mistake
cout%26lt;%26lt;i;
}
getch();
}
I am assuming that you have declared the void main() and header file inclusions properly.
Reply:the last loop closed by u doesn't have started by u
Reply:any c or cpp pgm should start with the main func. but u have not did it.
moreover it should have preprocessor directory files such as #include%26lt;iostream.h%26gt;,#include%26lt;conio.h%26gt;,#... ........
error in 1st line
there shouldnot b any comma or fullstop b4 the semicollen.
the correction should b made like dis
int i,n;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment