![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
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 |
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3
![]() |
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) |
|
|
|
|
#3 |
|
Hobbyist Programmer
|
it is coming up with an error on this {
|
|
|
|
|
#4 |
|
Hobbyist Programmer
|
if this helps i am using the program Dev C++
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3
![]() |
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;
}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) |
|
|
|
|
#6 |
|
Programmer
Join Date: Feb 2006
Location: UK
Posts: 36
Rep Power: 0
![]() |
if you want to use the word void (and to make the main slightly more clear) use
int main(void) |
|
|
|
|
#7 |
|
Hobbyist Programmer
|
ok i will try it that code you gave me and see if it works better.
|
|
|
|
|
#8 |
|
Hobbyist Programmer
|
the one that you gave me doesnt come up.
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 243
Rep Power: 3
![]() |
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) |
|
|
|
|
#10 |
|
Hobbyist Programmer
|
yes i am. it isnt bring no box up for my to do the counting thing.
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|