Wakeboarder Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   StatisticsStats   FavoritesFavorites   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages  Log inLog in 
BlogsBlogs   

C++ ANYONE?

 
Post new topic   Reply to topic    Wakeboarder Forum Index -> Technology, Photography, and Media
View previous topic :: View next topic  
Author Message
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 25, 2007 12:25 pm    Post subject: C++ ANYONE? Reply with quote

i am suppose to right this program. Have no understanding of C++ and I am sure it would take anyone like 5 min to write up could anyone help me out? Below is what I am to do:


Ask the user to enter a radius, calculate (and output) the circumference and area of the circle.
C= 2(pi)r
A=(pi)r^2

-use variable pi and set it to 3.14159
Back to top
View user's profile Send private message AIM Address
Wakebrad
Ladies Man
Ladies Man


Joined: 11 Dec 2003
Posts: 12257
City: Dallas

PostPosted: Apr 25, 2007 12:44 pm    Post subject: Reply with quote

It's been a couple years but here goes:

#include <iostream>
using namespace std;
int main()
{
double r;
double pi = 3.14159;
cout << "Enter the radius: ";
cin >> r;
cout << "The circumference is: " << 2.0*pi*r << " the area is: " << 1.0*pi*r^2 << endl;
return 0;
}

_________________
You have just entered the twilight zone.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Wakebrad
Ladies Man
Ladies Man


Joined: 11 Dec 2003
Posts: 12257
City: Dallas

PostPosted: Apr 25, 2007 12:52 pm    Post subject: Reply with quote

Oh, if that works the first time you owe me $5. You can PM me for my paypal.

Software never works the first try.

_________________
You have just entered the twilight zone.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 25, 2007 3:04 pm    Post subject: Reply with quote

alright I will let you know tomorrow once i get into the computer lab and try it..

i dont think i will ever make fun of a cis major again... this crap makes no sence to me
Back to top
View user's profile Send private message AIM Address
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 26, 2007 12:22 pm    Post subject: Reply with quote

got two errors

cin >> r; this line has an error of "unable to resolve function overload"

and

cout << "The circumference is: " << 2.0*pi*r << " the area is: " << 1.0*pi*r^2 << endl; has an error of mismath in formal parameter list
Back to top
View user's profile Send private message AIM Address
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 26, 2007 12:39 pm    Post subject: Reply with quote

cin >> r; this line is fine both errors are on the the other one i guess
Back to top
View user's profile Send private message AIM Address
Wakebrad
Ladies Man
Ladies Man


Joined: 11 Dec 2003
Posts: 12257
City: Dallas

PostPosted: Apr 26, 2007 12:44 pm    Post subject: Reply with quote

Sounds like your environment might not be setup right.

Try this one to see if you can at least get it to execute:

#include <iostream>
using namespace std;
int main()
{
double r;
cout<<"test";
return 0;
}

_________________
You have just entered the twilight zone.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Wakebrad
Ladies Man
Ladies Man


Joined: 11 Dec 2003
Posts: 12257
City: Dallas

PostPosted: Apr 26, 2007 12:45 pm    Post subject: Reply with quote

if they're both on that one line try this then:

#include <iostream>
using namespace std;
int main()
{
double r;
double pi = 3.14159;
cout << "Enter the radius: ";
cin >> r;
cout << "The circumference is: " << 2.0*pi*r << " the area is: " << 1.0*pi*r*r << endl;
return 0;
}

_________________
You have just entered the twilight zone.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 26, 2007 12:52 pm    Post subject: Reply with quote

dude you are the man
Back to top
View user's profile Send private message AIM Address
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 26, 2007 12:52 pm    Post subject: Reply with quote

what did you change?
Back to top
View user's profile Send private message AIM Address
b_girl
Wakeboarder.Commie
Wakeboarder.Commie


Joined: 10 Jul 2006
Posts: 1423
City: Toronto

PostPosted: Apr 26, 2007 12:53 pm    Post subject: Reply with quote

not to sound b***hy or anything but u coulda at least attempted it yourself before asking someone else to write it for you!

anyway, add this to the top:
#include "stdafx.h"

*edit* or not... haha, it's been a couple years since i touched C++
Back to top
View user's profile Send private message
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 26, 2007 12:56 pm    Post subject: Reply with quote

because I did try it myself.. this stuff means nothing to me i dont understand it one bit, the last assignment we had was to copy what he had and put it and and i got errors with no clue how to fix.

this is a intro class i took it as a gen ed aside from this the class was a joke.
Back to top
View user's profile Send private message AIM Address
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 26, 2007 12:57 pm    Post subject: Reply with quote

#include "stdafx.h"

what does this do?
Back to top
View user's profile Send private message AIM Address
Wakebrad
Ladies Man
Ladies Man


Joined: 11 Dec 2003
Posts: 12257
City: Dallas

PostPosted: Apr 26, 2007 1:05 pm    Post subject: Reply with quote

Ok, now that you know the problem and have the solution in front of you here's a little explanation.

#include <iostream>To write data to and from the screen you have to include this code so that the compiler recognises cin and cout
using namespace std;this defines the namespace, too complex to worry about yet
int main()This is where the code starts executing
{defines the opening of the function
double r;Declares a variable of type double. Integer is like 1,2,3,4,5. Double can have decimals: 2.4, 4.003, etc
double pi = 3.14159;define pi as a double and set it to the value
cout << "Enter the radius: ";cout<< writes to the screen
cin >> r;cin>> reads the screen into the variable r
cout << "The circumference is: " << 2.0*pi*r << " the area is: " << 1.0*pi*r*r << [/b]endl;This is the line with the problem. My mistake was that I thought r^2 would do exponent but I was wrong. What I changed it to was r*r.
return 0;This is the return value, you probably don't need to worry about this yet. Read your book or wait until your prof goes over functions/methods
}this closes the function

Your prof should have gone over some of this stuff already.

_________________
You have just entered the twilight zone.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 26, 2007 1:08 pm    Post subject: Reply with quote

wow i somewhat understand it actually, thank you. the prof is not a very helpful one he runs through slides in monolouge; I am sure you know a few profs like this.

Seriously, you have no idea how much you helped me out. I appreciate it
Back to top
View user's profile Send private message AIM Address
DJew Jake
Wakeboarder.com Freak
Wakeboarder.com Freak


Joined: 17 Sep 2003
Posts: 3907
City: Toronto

PostPosted: Apr 26, 2007 1:14 pm    Post subject: Reply with quote

If your taking the course are you going to expect us to write all your assignments?
_________________
They know what is what but they dono what is what they just strut.
Back to top
View user's profile Send private message MSN Messenger
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 26, 2007 1:16 pm    Post subject: Reply with quote

yeah can you get on my excel spreadsheets while your helping me out with this?
Back to top
View user's profile Send private message AIM Address
Wakebrad
Ladies Man
Ladies Man


Joined: 11 Dec 2003
Posts: 12257
City: Dallas

PostPosted: Apr 26, 2007 1:21 pm    Post subject: Reply with quote

I've had some profs like that, it's particularly bad in intro classes where the subject is totally new. The best way to learn is to use your book, type out the examples and run them.

No problem.

_________________
You have just entered the twilight zone.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DJew Jake
Wakeboarder.com Freak
Wakeboarder.com Freak


Joined: 17 Sep 2003
Posts: 3907
City: Toronto

PostPosted: Apr 26, 2007 1:25 pm    Post subject: Reply with quote

the reason ^ did not work is because that is a bit op in c++ when you go numbe^2 its xor with 2 isnt it?
_________________
They know what is what but they dono what is what they just strut.
Back to top
View user's profile Send private message MSN Messenger
b_girl
Wakeboarder.Commie
Wakeboarder.Commie


Joined: 10 Jul 2006
Posts: 1423
City: Toronto

PostPosted: Apr 26, 2007 1:26 pm    Post subject: Reply with quote

smwilliam2, sorry, didn't realize you had already tried it yourself. i've been roped into "helping" (or... doing) other peoples assignments before so i get a little annoyed by it now if the person hasn't at least made an attempt first.
Back to top
View user's profile Send private message
DJew Jake
Wakeboarder.com Freak
Wakeboarder.com Freak


Joined: 17 Sep 2003
Posts: 3907
City: Toronto

PostPosted: Apr 26, 2007 1:27 pm    Post subject: Reply with quote

incase your wonderng that means

lets sa radius - 7 thats 00000111
2 = 00000010

xor means one or the other but not both so the awsner would be

00000101 or 5

_________________
They know what is what but they dono what is what they just strut.
Back to top
View user's profile Send private message MSN Messenger
DJew Jake
Wakeboarder.com Freak
Wakeboarder.com Freak


Joined: 17 Sep 2003
Posts: 3907
City: Toronto

PostPosted: Apr 26, 2007 1:28 pm    Post subject: Reply with quote

but bit ops do not work on floating numbers thats why it didnt work.
_________________
They know what is what but they dono what is what they just strut.
Back to top
View user's profile Send private message MSN Messenger
smwilliam2
Soul Rider
Soul Rider


Joined: 16 Apr 2006
Posts: 252

PostPosted: Apr 26, 2007 1:29 pm    Post subject: Reply with quote

b_girl, yeah this is a forum where every gets on eachothers cases. but how do find yourself in doing stuff for others i mean you have a choice... maybe sub consciously you enjoy helping others lol
Back to top
View user's profile Send private message AIM Address
b_girl
Wakeboarder.Commie
Wakeboarder.Commie


Joined: 10 Jul 2006
Posts: 1423
City: Toronto

PostPosted: Apr 26, 2007 1:33 pm    Post subject: Reply with quote

smwilliam2, it starts out with them asking for help on how to start it... then help on how to do such-and-such, etc... and before you know it, i've done the whole thing. so now i'm a little more careful when people ask for help Smile

some people just cut right to the chase and ask me to do the whole thing... but then they're met with a big fat no.
Back to top
View user's profile Send private message
DJew Jake
Wakeboarder.com Freak
Wakeboarder.com Freak


Joined: 17 Sep 2003
Posts: 3907
City: Toronto

PostPosted: Apr 26, 2007 1:38 pm    Post subject: Reply with quote

I refuse to write you any code in c its so useless these days. Sorry.
_________________
They know what is what but they dono what is what they just strut.
Back to top
View user's profile Send private message MSN Messenger
Wakebrad
Ladies Man
Ladies Man


Joined: 11 Dec 2003
Posts: 12257
City: Dallas

PostPosted: Apr 26, 2007 1:40 pm    Post subject: Reply with quote

Wow, I haven't done C++ in 5 years. That's crazy. It doesn't seem like that long ago.

Interesting on the xor. Not sure I ever used that. I had a course in C and a course in C++ but work in ASP.NET and Java now.

I mooched off more people in highschool and college than I will ever be able to make up for. It feels good to give back a little Very Happy

_________________
You have just entered the twilight zone.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DJew Jake
Wakeboarder.com Freak
Wakeboarder.com Freak


Joined: 17 Sep 2003
Posts: 3907
City: Toronto

PostPosted: Apr 26, 2007 1:47 pm    Post subject: Reply with quote

Wakebrad, Ye well why use c++ managed languages are just as fast and you can insert assembler directly into them too so as far as im concrened c++ has very little use in todays world of on demand applications.
_________________
They know what is what but they dono what is what they just strut.
Back to top
View user's profile Send private message MSN Messenger
Wakebrad
Ladies Man
Ladies Man


Joined: 11 Dec 2003
Posts: 12257
City: Dallas

PostPosted: Apr 26, 2007 1:58 pm    Post subject: Reply with quote

Jibsta, interesting. I hadn't heard that C++ was on its way out.

I pretty much only do web apps so c++ has no use there. C# is going strong though.

_________________
You have just entered the twilight zone.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DJew Jake
Wakeboarder.com Freak
Wakeboarder.com Freak


Joined: 17 Sep 2003
Posts: 3907
City: Toronto

PostPosted: Apr 26, 2007 2:14 pm    Post subject: Reply with quote

Wakebrad, Well c has obvious uses for anything low level. But 90% of user apps are now writen in managed code. Languages like C# lets big companies higher less skilled in house programmers for cheaper so its win win for everyone. Anything "hard" to write will still be done in c++.
_________________
They know what is what but they dono what is what they just strut.
Back to top
View user's profile Send private message MSN Messenger
b_girl
Wakeboarder.Commie
Wakeboarder.Commie


Joined: 10 Jul 2006
Posts: 1423
City: Toronto

PostPosted: Apr 27, 2007 3:08 pm    Post subject: Reply with quote

c# is the way forward for sure, i haven't done that much in it yet, but i intend to... most of my experience in the past actually lies in C and C++... doing VB at my current job though...

wanna know something sad? we still update/support VB3 apps. our boss has been very hesitant to move to VB.Net - partially cuz he's got no clue what it is. BUT, think we've managed to convince him to allow us to start moving portions of our apps across to .net now.

Wakebrad, my project over the next few weeks is actually to redesign this one product of ours so it's accessible over the web (it's currently a 16-bit app so it's gonna take some work), so that means asp.net... i might come to you with questions Razz
Back to top
View user's profile Send private message
Wakebrad
Ladies Man
Ladies Man


Joined: 11 Dec 2003
Posts: 12257
City: Dallas

PostPosted: Apr 27, 2007 6:21 pm    Post subject: Reply with quote

b_girl, haha no problem. I'm actually just making the switch to 2.0 so I'm still learning the new stuff but once you get the concept you should be fine. also www.asp.net has pretty helpful forums that I use when I'm stumped.
_________________
You have just entered the twilight zone.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
b_girl
Wakeboarder.Commie
Wakeboarder.Commie


Joined: 10 Jul 2006
Posts: 1423
City: Toronto

PostPosted: Apr 28, 2007 9:51 am    Post subject: Reply with quote

Wakebrad, thanks - i'll keep that link in mind, except we don't have use of the internet at work Confused
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Wakeboarder Forum Index -> Technology, Photography, and Media All times are GMT - 8 Hours
Page 1 of 1

Add To Favorites

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
             


Copyright © 2012 - Wakeboarding - Wakeboarder.com - All Right Reserved
Powered by phpBB © 2001, 2005 phpBB Group