![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2005
Posts: 49
Rep Power: 0
![]() |
Tutorial Problem
ok im using an online tutorial that some one on this site(i forget who) posted a link for. its just a variable example it doesn't work.When i compile and run it all it does is just flash somthing then highlight the cout part. The tutorial i think is based towards Ansi-C++ but im using Dev-C++. Would that be that reason its not working?
here is the code: // operating with variables
#include <iostream.h>
using namespace std;
int main ()
{
// declaring variables:
int a, b;
int result;
// process:
a = 5;
b = 2;
a = a + 1;
result = a - b;
// print out the result:
cout << result;
// terminate the program:
return 0;
}first i tryed it on my own and it didn't work so then i just copied and pasted and it still did the same thing. What is the problem. I think its a compiler difference. ![]() |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 218
Rep Power: 4
![]() |
Works on my copy of dev c++, Whats it suppose to do, Just flashed a CMD window and then closed
|
|
|
|
|
|
#3 |
|
Expert Programmer
|
put in the line cin.get(); before return 0;
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#4 | |
|
Programmer
Join Date: Oct 2005
Posts: 49
Rep Power: 0
![]() |
Quote:
also ill reffer to this thread for later questions that i have about the tutorial, so i wouldn't half to make another thread. So if you see another post by me in this thread please read it because most likely it will be a question. |
|
|
|
|
|
|
#5 |
|
Expert Programmer
|
okay, glad to help. Which tutorial is this? i have bad memory.
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#6 |
|
Programmer
Join Date: Oct 2005
Posts: 49
Rep Power: 0
![]() |
the one on page 4 somewhere in the middle. Hello world.
Very Very helpful for a biginner to C++ like me. My programming class teaches visual basic but i heard that is teaches bad programming habits so i don't want to focus on that too much so i rather start learning C++ now. In the second half of the year my class turns into an andvanced computer programming class in which we will learn Java . Im in 9th grade and my goal is to make it to MIT. So i think its best for me to study everyday from now rather than trying cram stuff into my brain in like 11th grade. ![]() |
|
|
|
|
|
#7 |
|
Expert Programmer
|
good thinking
![]() http://www.programmingforums.org/for...ead.php?t=6057 here is the link, I'm going to ask a mod to move it to the tutorial section ![]()
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#8 |
|
Programmer
Join Date: Oct 2005
Posts: 49
Rep Power: 0
![]() |
like i said ill refer to this thread to ask other questions and i have another question.
whats wrong with this code: #include <iostream>
using namespace std;
int main()
{
int i;
cout << "please enter an integer value: ";
cin >> i;
cout << "the value you entered is" << i;
cout << "and its double is...\n";
cout << i*2;
return 0;
}what its suposed to do is that when a user enter a number its supposed to say "the value you entered is" then its supposed to show the value doubled. How does the user enter stuff i know that they have to put in a number but do they have to press enter? because if you have to press enter all it does is just exit the program when you press enter. Or is it supposed to pop up as soon as a value is entered. wow im confused ![]() |
|
|
|
|
|
#9 |
|
Programmer
Join Date: Oct 2005
Posts: 49
Rep Power: 0
![]() |
please i need help badly. I want to get this right before i go to sleep. I do not want to go to sleep with this on my mind. Ill never be able to take my mind off of it.
ex. last night i downloaded dev-c++ but i did not want to start learning c++ at night so i went to bed and guess what. I dreamt about reading and doing the tutorial. I woke up with a headache. lol im serious. |
|
|
|
|
|
#10 |
|
Programmer
Join Date: Sep 2005
Posts: 33
Rep Power: 0
![]() |
>> is the extraction operator,whenever we use cin a value is expected to be entered by the user,once the user enters the value and presses enter..>> then assigns this value to the variable('i' in this case)
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|