#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int lop, squr;
for (lop=1; lop<=20; lop=lop+1);
{
squr = lop*lop;
printf("%5d,%5d,\n",lop,squr);
}
getch();
}
my friend is saying is that this source code is working well.. but it is not working well at my side. what should I have to do to work well in C++ .
My Friend is saying to me that above mentioned code is working well in the version which he is using. I said, this code is incorrect and will give execution errors…. is above mentioned code is correct for any standard or version of C / C++.
and Also tell me that how many versions C++ are available…
Regards
for (lop=1; lop<=20; lop=lop+1);is the problem. Change tofor (lop=1; lop<=20; lop=lop+1)(remove the semicolon will make this work).This is your code, with problem fixed and optimized:
Lines with
// Remove if you wantcan be removed, but will change the behaviour. See @VinayakGarg’s comment.