Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Oct 26th, 2005, 5:43 PM   #1
D-Ferg27
Programmer
 
D-Ferg27's Avatar
 
Join Date: Oct 2005
Posts: 49
Rep Power: 0 D-Ferg27 is on a distinguished road
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.
D-Ferg27 is offline   Reply With Quote
Old Oct 26th, 2005, 5:47 PM   #2
zorin
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 218
Rep Power: 4 zorin is on a distinguished road
Works on my copy of dev c++, Whats it suppose to do, Just flashed a CMD window and then closed
zorin is offline   Reply With Quote
Old Oct 26th, 2005, 5:49 PM   #3
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
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.
coldDeath is offline   Reply With Quote
Old Oct 26th, 2005, 5:56 PM   #4
D-Ferg27
Programmer
 
D-Ferg27's Avatar
 
Join Date: Oct 2005
Posts: 49
Rep Power: 0 D-Ferg27 is on a distinguished road
Talking

Quote:
Originally Posted by coldDeath
put in the line cin.get(); before return 0;
haha silly me :o . I should of know. Cold Death i read your tutorial last night and read about that. how did i forget already


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.
D-Ferg27 is offline   Reply With Quote
Old Oct 26th, 2005, 5:59 PM   #5
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
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.
coldDeath is offline   Reply With Quote
Old Oct 26th, 2005, 6:22 PM   #6
D-Ferg27
Programmer
 
D-Ferg27's Avatar
 
Join Date: Oct 2005
Posts: 49
Rep Power: 0 D-Ferg27 is on a distinguished road
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.

D-Ferg27 is offline   Reply With Quote
Old Oct 26th, 2005, 6:25 PM   #7
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
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.
coldDeath is offline   Reply With Quote
Old Oct 26th, 2005, 9:35 PM   #8
D-Ferg27
Programmer
 
D-Ferg27's Avatar
 
Join Date: Oct 2005
Posts: 49
Rep Power: 0 D-Ferg27 is on a distinguished road
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
D-Ferg27 is offline   Reply With Quote
Old Oct 26th, 2005, 10:36 PM   #9
D-Ferg27
Programmer
 
D-Ferg27's Avatar
 
Join Date: Oct 2005
Posts: 49
Rep Power: 0 D-Ferg27 is on a distinguished road
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.
D-Ferg27 is offline   Reply With Quote
Old Oct 27th, 2005, 12:21 AM   #10
aloksave
Programmer
 
aloksave's Avatar
 
Join Date: Sep 2005
Posts: 33
Rep Power: 0 aloksave is on a distinguished road
>> 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)
aloksave 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 6:57 PM.

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