When I run this code the program freezes,why?
main()
{
int co;
co=0;
while (co<10) {
co=co+1;
if (co==3)
printf("The number is now three.");
if (co==7)
printf("The number is now seven.");
else
printf(co);
}
}
I’m compiling it with mingw GCC.
You can’t print
colike that:You need to do it like this:
printftakes as a first parameter, a string with format specifiers. The latter (optional) parameters are the arguments themselves.http://www.cplusplus.com/reference/clibrary/cstdio/printf/
Here’s a more cleaned version of your code: