Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 27th, 2005, 5:34 PM   #11
farnush
Newbie
 
Join Date: Oct 2005
Posts: 12
Rep Power: 0 farnush is on a distinguished road
ok here is what it says ... Declaration is not allowed here
farnush is offline   Reply With Quote
Old Oct 27th, 2005, 5:37 PM   #12
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4 ivan is on a distinguished road
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));    
  	}
  
 }
ivan is offline   Reply With Quote
Old Oct 27th, 2005, 5:40 PM   #13
Prm753
Professional Programmer
 
Prm753's Avatar
 
Join Date: Oct 2005
Location: United States
Posts: 447
Rep Power: 4 Prm753 is on a distinguished road
Send a message via AIM to Prm753 Send a message via MSN to Prm753
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
Prm753 is offline   Reply With Quote
Old Oct 27th, 2005, 6:03 PM   #14
Kaja Fumei
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 134
Rep Power: 4 Kaja Fumei is on a distinguished road
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.
Kaja Fumei is offline   Reply With Quote
Old Oct 27th, 2005, 8:37 PM   #15
ASMvsC++
Newbie
 
Join Date: Oct 2005
Posts: 12
Rep Power: 0 ASMvsC++ is on a distinguished road
That's strange !!! I can declare vari anywhere I wann and it make no err
ASMvsC++ is offline   Reply With Quote
Old Oct 27th, 2005, 9:32 PM   #16
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
>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.
Narue is offline   Reply With Quote
Old Oct 27th, 2005, 10:14 PM   #17
ASMvsC++
Newbie
 
Join Date: Oct 2005
Posts: 12
Rep Power: 0 ASMvsC++ is on a distinguished road
Quote:
Originally Posted by Narue
>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.
But the asker say he using Turbo C 3.0 it is --> C++
ASMvsC++ is offline   Reply With Quote
Old Oct 28th, 2005, 3:59 AM   #18
farnush
Newbie
 
Join Date: Oct 2005
Posts: 12
Rep Power: 0 farnush is on a distinguished road
it works if it i use b4 the clrscr ();
farnush is offline   Reply With Quote
Old Oct 29th, 2005, 10:13 AM   #19
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Nov 2nd, 2005, 1:39 AM   #20
kurt
Programmer
 
Join Date: Oct 2005
Posts: 72
Rep Power: 4 kurt is on a distinguished road
Quote:
Originally Posted by tempest
Next time try pasting code you've written with the [Enter] key...

All that's saying is that clrscr() is not defined. Add this under your includes...

#ifdef WIN32
#    define clrscr() system("cls")
#else
#    define clrsrc() printf("\033c")
#endif
if i work in windows environment, does it automatically defines WIN32, or do i have to compile in the following manner:

gcc a.c -DWIN32
kurt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC