![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Newbie
Join Date: Oct 2005
Posts: 12
Rep Power: 0
![]() |
ok here is what it says ... Declaration is not allowed here
|
|
|
|
|
|
#12 |
|
Professional Programmer
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4
![]() |
Here is what I have changed and now it works:
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
system("cls");
int i;
for (i=1;i<10;i++)
{
printf("the values of the square root of %d is %d \n",i,sqrt((double)i));
}
} |
|
|
|
|
|
#13 |
|
Professional Programmer
|
Worked fine with TurboC V 1.01 for me.
__________________
The world's first athletic computer geek! The home of PrProgramsStudios How not to post a question: <-- Please don't reply |
|
|
|
|
|
#14 |
|
Hobbyist Programmer
Join Date: Oct 2005
Posts: 134
Rep Power: 4
![]() |
Am I the only one that read Narue's post? Narue is right:
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
int i;
clrscr();
for (i=1;i<10;i++)
{
printf("the values of the square root of %d is %d \n",i,sqrt((double)i));
}
return 0; /* I added this too */
}In C, you have to declare all your variables before executing anything. i's declaration was after the call to clrscr() so it was illegal. |
|
|
|
|
|
#15 |
|
Newbie
Join Date: Oct 2005
Posts: 12
Rep Power: 0
![]() |
That's strange !!! I can declare vari anywhere I wann and it make no err
|
|
|
|
|
|
#16 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>That's strange !!! I can declare vari anywhere I wann and it make no err
It's not strange at all. You're compiling as C++, not C.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#17 | |
|
Newbie
Join Date: Oct 2005
Posts: 12
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#18 |
|
Newbie
Join Date: Oct 2005
Posts: 12
Rep Power: 0
![]() |
it works if it i use b4 the clrscr ();
|
|
|
|
|
|
#19 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
This thread is indicative of exactly what a thread should not be. Except for Narue's correct posts, it is largely a recommendation to the OP that he/she indulge in voodoo programming. That sucks. As to ASMvsC++'s last post: most C++ compilers are capable of compiling a program as either C or C++. The choice between the two may be made in various ways (including, sometimes, the file extension).
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#20 | |
|
Programmer
Join Date: Oct 2005
Posts: 72
Rep Power: 4
![]() |
Quote:
gcc a.c -DWIN32 |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|