Programming Forums
User Name Password Register
 

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

Closed Thread
 
Thread Tools Display Modes
Old Mar 10th, 2006, 10:54 AM   #1
demon101
Hobbyist Programmer
 
demon101's Avatar
 
Join Date: Mar 2006
Location: westboro, ohio
Posts: 159
Rep Power: 0 demon101 is an unknown quantity at this point
Send a message via Yahoo to demon101
problem with a code

i am having a problem with a code i am trying to do

// Hey Everyone
//Welcome:
//Counting from 0 to 10

#include
using namespace std;

void main ()
           {
     // declare a variable
     int i;
     for(i= 0; i < 11; i++)
     count << i << endl;
     }
     /*this opens the comment:
            this is the generated output:
                 0
                 1
                 2
                 3
                 4
                 5
                 6
                 7
                 8
                 9
                 10
                 /* this cloese comment
demon101 is offline  
Old Mar 10th, 2006, 11:00 AM   #2
Soulstorm
Hobbyist Programmer
 
Soulstorm's Avatar
 
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3 Soulstorm is on a distinguished road
first of all, try to specify what the problem is. I assume you get compilation errors.

second, you should type "cout", not "count" for the output to be displayed correctly.
__________________
Project::Soulstorm (personal homepage)
Soulstorm is offline  
Old Mar 10th, 2006, 11:02 AM   #3
demon101
Hobbyist Programmer
 
demon101's Avatar
 
Join Date: Mar 2006
Location: westboro, ohio
Posts: 159
Rep Power: 0 demon101 is an unknown quantity at this point
Send a message via Yahoo to demon101
it is coming up with an error on this {
__________________
Demon101 Production's

Code Forums
demon101 is offline  
Old Mar 10th, 2006, 11:05 AM   #4
demon101
Hobbyist Programmer
 
demon101's Avatar
 
Join Date: Mar 2006
Location: westboro, ohio
Posts: 159
Rep Power: 0 demon101 is an unknown quantity at this point
Send a message via Yahoo to demon101
if this helps i am using the program Dev C++
__________________
Demon101 Production's

Code Forums
demon101 is offline  
Old Mar 10th, 2006, 11:07 AM   #5
Soulstorm
Hobbyist Programmer
 
Soulstorm's Avatar
 
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3 Soulstorm is on a distinguished road
what compiler you are using is irrelevant, since the mistakes you have made are not compiler-specific. try using this code:

// Hey Everyone
//Welcome:
//Counting from 0 to 10

#include <iostream>
using namespace std;

int main ()
{
	// declare a variable
	int i;
	for(i= 0; i < 11; i++)
		cout << i << endl;
    return 0;
}
Compare this code with the one you gave me and see why are you getting these errors.

Hope I helped.

FIRST OF ALL:
Do not use "void" in "main". "main()" must return an integer number at the end. The "void" in "main()" was used in previews editions of the language and now it is abandoned. Older compilers will work with "void main()", but newer ones, such as DevC++, with require "int main()".

Try looking closely at the code you write, and you will see that most errors you make are mistypings.
__________________
Project::Soulstorm (personal homepage)
Soulstorm is offline  
Old Mar 10th, 2006, 11:40 AM   #6
.TD
Programmer
 
.TD's Avatar
 
Join Date: Feb 2006
Location: UK
Posts: 36
Rep Power: 0 .TD is on a distinguished road
if you want to use the word void (and to make the main slightly more clear) use
int main(void)
meaning the main function does not take any parameters (such as command line arguments)
__________________
Go away before I replace you with a very small shell script.
--
Get FireFox!
.TD is offline  
Old Mar 10th, 2006, 11:50 AM   #7
demon101
Hobbyist Programmer
 
demon101's Avatar
 
Join Date: Mar 2006
Location: westboro, ohio
Posts: 159
Rep Power: 0 demon101 is an unknown quantity at this point
Send a message via Yahoo to demon101
ok i will try it that code you gave me and see if it works better.
__________________
Demon101 Production's

Code Forums
demon101 is offline  
Old Mar 10th, 2006, 11:55 AM   #8
demon101
Hobbyist Programmer
 
demon101's Avatar
 
Join Date: Mar 2006
Location: westboro, ohio
Posts: 159
Rep Power: 0 demon101 is an unknown quantity at this point
Send a message via Yahoo to demon101
the one that you gave me doesnt come up.
__________________
Demon101 Production's

Code Forums
demon101 is offline  
Old Mar 10th, 2006, 12:24 PM   #9
Soulstorm
Hobbyist Programmer
 
Soulstorm's Avatar
 
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3 Soulstorm is on a distinguished road
what do you mean "doesn't come up"? there is nothing wrong with the code. are you doing everything right in DevC++?
__________________
Project::Soulstorm (personal homepage)
Soulstorm is offline  
Old Mar 10th, 2006, 12:30 PM   #10
demon101
Hobbyist Programmer
 
demon101's Avatar
 
Join Date: Mar 2006
Location: westboro, ohio
Posts: 159
Rep Power: 0 demon101 is an unknown quantity at this point
Send a message via Yahoo to demon101
yes i am. it isnt bring no box up for my to do the counting thing.
__________________
Demon101 Production's

Code Forums
demon101 is offline  
Closed Thread

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:15 AM.

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