techPowerUp! Forums

Go Back   techPowerUp! Forums > Software > Programming & Webmastering

Reply
 
Thread Tools
Old 11-08-2009, 08:58 PM     #26
Munki
250 Posts
 
Munki's Avatar
 
Join Date: Sep 2008
Location: Georgia
Posts: 299 (0.69/day)
Thanks: 21
Thanked 23 Times in 20 Posts
Send a message via AIM to Munki

System Specs

Quote:
Originally Posted by Kreij View Post
Having a book for reference will come in handy, Munki. It's easier that always having to search through the net for answers for basics.

As soon as you get some code going, post it here so we can take a look at it and help you out.

PS. I have no idea what Onafets is talkiing about either. lol


Well, I did it made a simple calculator, and then amazingly deleted it (perminatly)


ALTHOUGH! Im going to redo it anyways just to give me more practice, and then ill post the code up.
__________________


Referances:
Heatware: ipphreak
ebay: mollymay506
amazon: insane_monkay
Munki is online now  
Reply With Quote
Old 11-08-2009, 09:31 PM     #27
andrewsmc
500 Posts
 
andrewsmc's Avatar
 
Join Date: Sep 2008
Location: Austin Texas
Posts: 618 (1.43/day)
Thanks: 148
Thanked 37 Times in 33 Posts

System Specs

Reading all this just makes me feel stupid!

__________________

PARTING OUT MY i7 RIG! http://forums.techpowerup.com/showthread.php?t=108051
andrewsmc is offline  
Reply With Quote
Old 11-09-2009, 12:57 AM     #28
Munki
250 Posts
 
Munki's Avatar
 
Join Date: Sep 2008
Location: Georgia
Posts: 299 (0.69/day)
Thanks: 21
Thanked 23 Times in 20 Posts
Send a message via AIM to Munki

System Specs

Okay so I just did a simple code. It wasnt compiled or debuged. Im copy and paste straight from my script.

Code:
#include <iostream>
#include <cstdlib>

using namespace STD;

int main()

{
  double num;
  double num2;
  char input;
  For (;;)
  { 
  
  Do
   {
  
  COUT << "Welcome to Th3 C41c";
  COUT << "To begin Choose what function you would like to preform from the list provided for you";
  COUT << "1 - Addition";
  COUT << "2 - Subtraction";
  Cout << "3 - Multiplication";
  Cout << "4 - Divide";
  Cin >> input
  }
  while ( input > 1 || input < 4 );
  { Case '1';
          Cout << "Please enter your first number";
          Cin >> num;
          Cout << "Please enter your second number";
          cin >> num2;
          Cout << num + num2;
    Case '2';
          Cout << "Please enter your first number";
          Cin >> num;
          Cout << "Please enter your second number";
          Cin >> num2;
          Cout << num - num2;
   Case '3';
          Cout << "Please enter your fist number";
          Cin >> num;
          Cout << "please enter your second number";
          cin >> num2;
          Cout << num * num2;
   Case '4';
          Cout << "Please enter your first number";
          Cin >> num;
          Cout << "Please enter your second number";
          Cin >> num2;
          Cout << num / num2;
          }
Return 0;
}
__________________


Referances:
Heatware: ipphreak
ebay: mollymay506
amazon: insane_monkay
Munki is online now  
Reply With Quote
Old 11-09-2009, 01:19 PM     #29
Kreij
TPU Hit Squad Member
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 3,240 (3.18/day)
Thanks: 92
Thanked 766 Times in 581 Posts

System Specs

You have a couple of problems.

First, you while statment is only looping on 2 and 3.
You want to fo something like (input >= 1 && input <= 4) so you include 1 and 4

You will also need a switch statement in order to use the case statements
Code:
switch (input)
{
    Case '1':
    .....
}
Notice the case statement ends with a colon, not a semicolon.
__________________
53452340602F55453253602E35572D$20
Kreij is offline  
Reply With Quote
The Following User Says Thank You to Kreij For This Useful Post:
Old 11-09-2009, 03:38 PM     #30
Munki
250 Posts
 
Munki's Avatar
 
Join Date: Sep 2008
Location: Georgia
Posts: 299 (0.69/day)
Thanks: 21
Thanked 23 Times in 20 Posts
Send a message via AIM to Munki

System Specs

Quote:
Originally Posted by Kreij View Post
You have a couple of problems.

First, you while statment is only looping on 2 and 3.
You want to fo something like (input >= 1 && input <= 4) so you include 1 and 4

You will also need a switch statement in order to use the case statements
Code:
switch (input)
{
    Case '1':
    .....
}
Notice the case statement ends with a colon, not a semicolon.

Oh okay.Well there wasn't as many mistakes as I thought there was going to be. haha. I fully understand everything but the For loop portion of my mistake. Im going to fix that and try to figure that out. For my first real code, it wasnt that bad.
__________________


Referances:
Heatware: ipphreak
ebay: mollymay506
amazon: insane_monkay
Munki is online now  
Reply With Quote
Old 11-09-2009, 06:38 PM     #31
Munki
250 Posts
 
Munki's Avatar
 
Join Date: Sep 2008
Location: Georgia
Posts: 299 (0.69/day)
Thanks: 21
Thanked 23 Times in 20 Posts
Send a message via AIM to Munki

System Specs

Sorry for the double post, but this is irrealivant to what the previous post said and if i were to edit, no one would see it as they have already looked at it without this.


Can I buy a complier? If so, Where?

(p.s. I just made another calculator that does Square Root. When Visual Studio gets done downloading i will test and post if anyone wants to see it.)
__________________


Referances:
Heatware: ipphreak
ebay: mollymay506
amazon: insane_monkay
Munki is online now  
Reply With Quote
Old 11-09-2009, 08:08 PM     #32
Kreij
TPU Hit Squad Member
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 3,240 (3.18/day)
Thanks: 92
Thanked 766 Times in 581 Posts

System Specs

You can download Microsoft's C++ express for free.
http://www.microsoft.com/Express/VC/
__________________
53452340602F55453253602E35572D$20
Kreij is offline  
Reply With Quote
Old 11-09-2009, 09:13 PM     #33
Munki
250 Posts
 
Munki's Avatar
 
Join Date: Sep 2008
Location: Georgia
Posts: 299 (0.69/day)
Thanks: 21
Thanked 23 Times in 20 Posts
Send a message via AIM to Munki

System Specs

Quote:
Originally Posted by Kreij View Post
You can download Microsoft's C++ express for free.
http://www.microsoft.com/Express/VC/
Well I just downloaded the Microsoft Visual Studio 2010 Beta 2. Do you feel one is better than the other?
__________________


Referances:
Heatware: ipphreak
ebay: mollymay506
amazon: insane_monkay
Munki is online now  
Reply With Quote
Old 11-10-2009, 03:07 AM     #34
Kreij
TPU Hit Squad Member
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 3,240 (3.18/day)
Thanks: 92
Thanked 766 Times in 581 Posts

System Specs

In all honesty, Munki, at the level you are programming any version will do fine.
No offense intended, but you have to start somewhere and you are off to a great start !!!
I think that you find using the Integrated Development Environment (IDE) that the Visual Studio products integrate will make you life much easier.
Don't worry about what compiler/IDE is better, work on learning using the language you are working with, and in particular, learn the basics very well.

Keep the questions coming.
__________________
53452340602F55453253602E35572D$20
Kreij is offline  
Reply With Quote
Old 11-10-2009, 03:27 PM     #35
Munki
250 Posts
 
Munki's Avatar
 
Join Date: Sep 2008
Location: Georgia
Posts: 299 (0.69/day)
Thanks: 21
Thanked 23 Times in 20 Posts
Send a message via AIM to Munki

System Specs

Quote:
Originally Posted by Kreij View Post
In all honesty, Munki, at the level you are programming any version will do fine.
No offense intended, but you have to start somewhere and you are off to a great start !!!
I think that you find using the Integrated Development Environment (IDE) that the Visual Studio products integrate will make you life much easier.
Don't worry about what compiler/IDE is better, work on learning using the language you are working with, and in particular, learn the basics very well.

Keep the questions coming.


No offense taken (I know its true )


I built another script that does, Addition, Subtraction, Multiplication, Division and square root. I'm getting errors that i cant find the error. I ran debugger but I do not understand why its like that, I go back to the line(s) and it appears right to me. Ill access my external and post up the code in case you have time time to check it out.

Code:
#include <iostream>
#include <math>
#include <cstdlib>

using namespace STD;

int main ()

{
 Double num;
 Double num2;
 Char input;
 For (;;)
{ 
 Cout << " Please select your function. ";
 COut << " 1 - Addition ";
 Cout << " 2 - Subtraction";
 Cout << " 3 - Multiplication ";
 Cout << " 4 - Division ";
 Cout << " 5 - Square Root:;
}
While ( input <= '1' && input >= '5' )
Switch (input)
{
 Case '1':
	Cout << " Please input your first number ";
	Cin >>  num;
	Cout << " Please input your second number ";
	Cin >> num2;
	Cout << num + num2;
 Case '2':
	Cout << " Please input your first number ";
	Cin >> num;
	Cout << " Please input your second number ";
	Cin >> " num2;
	Cout << num - num2; 
 Case '3':
	Cout << "Please input your first number ";
	Cin >> num;
	Cout << "Please input your second number ";
	cin >> num2;
	Cout num * num2;
 Case '4':
	Cout << " Please input your first number ";
	Cin >> num;
	Cout << " Please input your second number ";
	Cin >> num2;
	Cout << num / num2;
 Case '5':
	Cout << " Please input the number you want to find the square root of. ";
	Cin >> num;
	if ( num < 0 )
{
 	Cout << "Number is negative. ";
}
	Else
{ 
	num2 = sqrt(num);
	Cout << num2;
}
Return 0;
}

I'm going to continue to try to locate this error.
__________________


Referances:
Heatware: ipphreak
ebay: mollymay506
amazon: insane_monkay
Munki is online now  
Reply With Quote
Old 11-10-2009, 03:48 PM     #36
Kreij
TPU Hit Squad Member
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 3,240 (3.18/day)
Thanks: 92
Thanked 766 Times in 581 Posts

System Specs

Code:
While ( input <= '1' && input >= '5' )
This is backward ... should be (input >= '1' && input <= '5')

Also in case '3' The output should be cout << num * num2; (You are missing the '<<')

What error are you getting ?
__________________
53452340602F55453253602E35572D$20

Last edited by Kreij; 11-10-2009 at 04:25 PM.
Kreij is offline  
Reply With Quote
Old 11-10-2009, 06:42 PM     #37
Munki
250 Posts
 
Munki's Avatar
 
Join Date: Sep 2008
Location: Georgia
Posts: 299 (0.69/day)
Thanks: 21
Thanked 23 Times in 20 Posts
Send a message via AIM to Munki

System Specs

Well for the most part it was claiming that COUT, and CIN were not called (initiated)


My compiler is installing on this computer. I wish I could install it on a jump drive so I didn't have to install it on 7 computers.


Im going to add some 'breaks' throughout the code to keep it from leaking through. I fixed my less than and greater than error. As well as my COUT error. Im going to end the forever loop, seeing as to how I blankly failed to do so. And finally added my Switch statement within the brackets.
__________________


Referances:
Heatware: ipphreak
ebay: mollymay506
amazon: insane_monkay

Last edited by Munki; 11-10-2009 at 07:04 PM.
Munki is online now  
Reply With Quote
Old 11-10-2009, 07:23 PM     #38
Munki
250 Posts
 
Munki's Avatar
 
Join Date: Sep 2008
Location: Georgia
Posts: 299 (0.69/day)
Thanks: 21
Thanked 23 Times in 20 Posts
Send a message via AIM to Munki

System Specs

Isnt
#include <iostream> suppose to declare COUT and CIN?
__________________


Referances:
Heatware: ipphreak
ebay: mollymay506
amazon: insane_monkay
Munki is online now  
Reply With Quote
Old 11-10-2009, 10:19 PM     #39
Kreij
TPU Hit Squad Member
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 3,240 (3.18/day)
Thanks: 92
Thanked 766 Times in 581 Posts

System Specs

If you are using Visual C++ add #include "stdafx.h" above the iostream include.

Don't capitalize cout.
__________________
53452340602F55453253602E35572D$20
Kreij is offline  
Reply With Quote
Reply


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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Which audio to use theonetruewill General Hardware 6 07-10-2007 11:54 PM
Which program to use trt740 Overclocking & Cooling 4 05-29-2007 08:56 PM
Which to use gerrynicol Graphics Cards 20 08-29-2006 08:32 PM
Which should i use? BigD6997 Graphics Cards 5 07-06-2006 12:48 AM


All times are GMT. The time now is 04:35 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
no new posts