Monday, May 24, 2010

Exponents in C++?

I just recently started learning C++ and I'm trying to write my first basic program. I decided to make one that would calculate the future value of an annuity when the user enters the present value, interest rate, and time.


Here's the code for the program. (I couldn't put the whole code, so I stripped out all the couts and cins.) The problem is in the 8th line with text in it. I need to make FV = PV * (1 + interest)^months. For some reason I can't use the ^ symbol for exponents.





#include %26lt;iostream%26gt;


using namespace std;


int main()


{


string exit;


typedef float f;


f PV, interest, months, FV;





FV = PV * (1 + interest)





cout %26lt;%26lt; "The future value of your deposit will be: $" %26lt;%26lt; FV %26lt;%26lt;endl;





cin%26gt;%26gt;exit;


return 0;


}

Exponents in C++?
use the math.h library





pow()
Reply:use: f(x)pow(exponent)
Reply:you us math or you do it manually





base, more ,x,y as int





base= 1000$


more= 1000 depot each year


x= 1,065


y=10 years





i=0;


base = base * x


for (i%26lt;y;i++)


{


base = base + more


base * x


}











look like that have fun


if you dont use labrary it take less place and it will run faster


I can't find a good book on C#?

I tried several books , C# For Dummies excellent until you start the OOP chapters. Poorly explained with bad examples.





C# from Sam's is also ok but when it comes to the OOP it use a lot of math examples and does not make its point.





I got Learning C# 2005 from Oreilly , I had no idea that oreilly books assume a programming background. So that one was also a waste of time





Guys any idea where I could get a good book? I check Amazon and found one from Mr Smiley. It is expensise but I don';t know if it is worth to buy. So far I purchased 4 books none can teach me OOP. I am ok with the loping %26amp; all that though.

I can't find a good book on C#?
Hi Joe,


My site below under Computer Talk has a link to a lot of online free books and tutorials that should help get you headed in the right direction. Hope this helps

tropical flowers

Can someone help me with C++?

Hi, i am just learning C++ and 3d mapping... can someone help me either give me a link or explain how to incoperate the map into C++? i know i sound like a total n00b but please help... thanks in advanced

Can someone help me with C++?
try http://www.cplusplus.com it has a lot of information.
Reply:no


Do you know of a c++ interactive training tool?

Hello there, I've been learning c++ from a couple of book for the last 2 weeks. I've read through about 600 page so far, starting from scratch and doing all the examples in the books.





Its proving to be very very laborious and I also can't really afford £1400 for a 5 day course to cover everything.





What would be really good is an interactive c++ leanrning tool, but I can't find one.





Would you know of one?

Do you know of a c++ interactive training tool?
Yes, we call them compilers. And some of the best are free. Check out the links, compilers, editors, IDEs and tutorials on the URL below.


If you are already using one, that is about as good as anyone can do. Some free advice is this: *SLOW DOWN*. It is better, far better IMHO, in the beginning to work through the examples slowly, modify the code so you get a real idea of which statements and variables create / control /destroy what and a *REAL* working foundation. I don't know if this is your first language or your three hundredth, but C++ is too complex to grasp in 5 days, 5 months or even likely in 5 years. Try backing up and reworking through some other tutorials, then back to the book(s) you've already got. Do you know C? How about the Win32s API? MFC? Free libraries of any kind? It is difficult to give advice to someone not knowing where in the process of learning a language they are at. Stay at it, ask questions (smart ones with enough details) on forums and slow up a bit so it absorbs. Good luck!
Reply:You can buy this book


Its really nice and detailed and most likely, the training program that costs 1400 would use this book as a guide





http://www.deitel.com/books/cppsimply1/
Reply:Not an interactive one but i do have an e-book.


if u want it you can select this as the best answer and mail me at ark_alok@yahoo.co.in with a proper subject.


How to move my " Visual C# Express Edition "(the entire working program) from one sytem to another ?

I am currently learning C# on Visual Studio Express Edition


for few weeks on a system.Now i am in a need to work on


a different sytem in which the program is not installed ;


can i simply copy the "visual studio" from "program files" from one sytem to another , i have come to know that program like this e.g .net sdk have their necessary files distributed at various locations (c:\windows\..etc) %26lt;also i want to mention installation via "http://msdn.." again is not feasible%26gt;


...........so please somebody tell me the detailed list of files i actually need to "copy and paste" for the same task ?

How to move my " Visual C# Express Edition "(the entire working program) from one sytem to another ?
It will be hard to do it this way(not impossible but hard). I will try one more time on a system that have Internet to save the package and then copy it to a system without Internet


Easy c++ game ideas?

i recently started learning c++ 3 days ago and i'm interested in making console based games any ideas for an easy but fun game?





thanx!!

Easy c++ game ideas?
My first computer game program was black jack. Who could resist that?





It's nice because it uses just enough tricks and tools for the new programmer:


- random number generation


- get user input (agree to another card or stay)


- storage array for 5 cards


- a loop for getting the 5 cards, and no more than 5 (rules, right?)


- summing the cards, analyzing if user is over, under, Winner





---Easy to expand on the game as you gain programming proficiency:


- play the dealer (computer, or even 2nd user)


- fancy display of cards, instead of just names/numbers


- sounds and images to signal win or loose...


- develop an array of 52 cards that is randomly sorted and picked off, like a real deck...


- develop a betting/payout system...calc odds so payout stays at 15% like a casino...





If you like math, probability, simple gaming, and gathering experince fast with a game you and others might actually enjoy, this could be it.





you go!
Reply:Seems that you are the very beginner, so start simple.





Then try to make some game which requires handling of random behavior, like playing rock, paper, scissors with computer.


Then try to make Snake. It is easiest thing you can try to do.





The next stage is building world. Try to build simple world using sprites and tiles (square images). The game world dont have to be sophisticated, just static images are enough at first time.





Add player actor into the world try to add motion to it: going left, right, up, down.





The hardest part of making game is to add computer controlled actors cos you should consider many things:


- movement (basic geometrics, calculating angle of movement, angle of firing)


- collision detection (what if two actors collide?)


- action behavior (which requires some AI techniques)


- event response (also AI)








Making games even simple one is not easy task. So start small. Then incrementally upgrade your game.
Reply:number munchers
Reply:I thought about doing this for a while, but never got around too it. Make a MUD ! Its all text based, don't have to worry about graphics at all. The user selects actions based on choices you provide and they type what action they want to do.





Could be a real simple MUD





A) Attack dragon using melee


B) Cast Spell


C) Move RightF


D) Move Left


E) Move up


F) Move Down





I was thinking of doing this and making it real simple. Simple spells and weapons. No inventory would be used. No food.





the only tricky part really would be keeping track of where the player was in the room and navigating around the dungeon.

sound cards

Can C++ be used for video game designing?

I'm learning C++ and am curious as to what would be a fun applictaion for it.

Can C++ be used for video game designing?
Yes, it can, and it most certainly is. About 70 percent of commercial games on the market are made in C/C++.





Then again... 99 percent of statistics are made up. :) Lol





Anyway, game designing is most definately something that you can use C++ for, and is a very common use for it.





Have fun!
Reply:not just video game designing but each and every designing.
Reply:Yes, you can do it via c++ with the help of any supportive languages if you want to more help so visit Given URL below





http://www.commediait.com
Reply:check out Blizzard's job postings, see what they look for from people who apply for their programming positions. You see C++ , C++, C++ all the time. ADVANCED SKILLS in C++, X years of experience in C++.





http://www.blizzard.com/jobopp/


C. Describe three strategies for working with children with learning disabilities.?

Multisensory techniques are frequently used for students with Learning Disabilities (LD) and include teaching strategies and materials that stimulate learning by enabling students to use some or all of their senses to:





Gather information about a task;


Link information to ideas they already know and understand;


Perceive the logic involved in solving problems;


Learn problem-solving steps;


Understand relationships between concepts; and


Learn information and store it for later recall.





Students with LDs typically have learning differences in one or more areas of reading, writing, math, listening comprehension, and expressive language. Multisensory techniques enable students to use their personal areas of strength to help them learn. They can range from simple to complex, depending on the needs of the student and the task at hand.





Learning Style Tests http://www.engr.ncsu.edu/learningstyles/...





http://www.scholastic.com/familymatters/...





http://homeworktips.about.com/od/homewor...





http://www.usd.edu/trio/tut/ts/style.htm...


In c++, how do I check if file length is zero?

I am doing a quiz project for the school exam. I have to check if file length of a file is zero ( concept of files). Can I use tellg() ?


I am implementing it in a class .Then I use if() statement to check if file length of a file which stores the quiz questions is zero( i.e there are no questions). If it is zero Then I invoke another function asking the user to input questions first.


Here should i use tellg() to check if there are no questions in the file.








P.s: I don't want it to be too complex...as I've been learning c++ only from june 2006

In c++, how do I check if file length is zero?
This page seems to have what you want.
Reply:May be my blog helps you. I have some code related to file handling in C++ at http://codesbyshariq.blogspot.com
Reply:you can use fstat to check if a file exists. it returns -1 if the file does not exist.





this function also exists on windows.
Reply:Use this method:





======================================...


#include %26lt;fstream%26gt;


int FileSize(const char* sFileName)


{


std::ifstream f;


f.open(sFileName, std::ios_base::binary | std::ios_base::in);


if (!f.good() || f.eof() || !f.is_open()) { return 0; }


f.seekg(0, std::ios_base::beg);


std::ifstream::pos_type begin_pos = f.tellg();


f.seekg(0, std::ios_base::end);


return static_cast%26lt;int%26gt;(f.tellg() - begin_pos);


}


======================================...





Drawback: If the file size is bigger than what int can hold, this method won't work, but in your case, you will be using it to check whether file size is 0, so it will work fine.








If you want to eliminate the limitation of int datatype, and if you are using Visual C++ compiler, then you can use the following function:





======================================...


#include %26lt;sys\types.h%26gt;


#include %26lt;sys\stat.h%26gt;


__int64 FileSize64( const char * szFileName )


{


struct __stat64 fileStat;


int err = _stat64( szFileName, %26amp;fileStat );


if (0 != err) return 0;


return fileStat.st_size;


}


======================================...


How can you make c++ program end itself?

Whenever a c++ program that I make ends, no matter whether it is by using "return" or "exit(0)", it always displays, "Press any key to continue" before the window closes itself. Is there a way to get rid of this message and have the window close itself without having to press a key?


I am just learning c++ and I haven't been able to find the answer to this question anywhere else. I've got Microsoft Visual Studio.net 2003.


Thanks

How can you make c++ program end itself?
this is a default benefit provided by ms. otherwise u need to use getch() to get the output on ur screen or press alt+f5.


if u want to remove it there is pragma supress. but to get upto that point u need to kow a lot. till then keep suffering. :)or use any other compiler like turbo c++
Reply:Miscrosoft Visual studio provide this facility by default .. if u wan to change browse seetings ..if u can't chnage it use other compilers like borland or turbo ..well ur learning ..i think these complilers will make u sense of Basics also .
Reply:use getch()


that shld be fine acc to me.

liama-song

An example of iTunes SDK implementation in C or C++?

I'm trying to control iTunes from a C program, and the simpler way seems to be through iTunes SDK, but I lack the knowledge to do so on my own (just begun learning C). Could someone provide me with sample code, or a better way to achieve this?


Thanks in advance.

An example of iTunes SDK implementation in C or C++?
You really might want to learn C++ first. The SDK will present examples to you, and an API. If you cannot understand it, that means you don't have the prerequisite knowledge to work with it. No, we cannot help you with that. If we present code, you'll give us a deer-in-the-headlights look because you don't know C.
Reply:Believe me it is complex. Why do not you contact a C++ expert?


Try http://expert.myitcareer.org/


Recommended C++ Compiler for beginners?

I want to start learning C++ programing, what compiler can you recommend me?





PS - I use Windows XP 64-bit, so just recommend me a working compiler for the operating system.





Thank You

Recommended C++ Compiler for beginners?
GCC has the advantage of being pretty good in adhering to standards, but if you're used to working under Windows, it may be a bit hard to get used to. You can download it here:


http://gcc.gnu.org/releases.html





Dev-C++ is used quite often, I've seen many people asking questions about it on this forum. You can download it here:


http://www.bloodshed.net/download.html





And then there's Microsoft Visual Studio C++ 2005 Express Edition. This edition is free but has its limitations (compared to a professional edition); on the other hand, if you're a beginning programmer, you won't run into those limitations very quickly. You can download it here:


http://msdn2.microsoft.com/en-us/express...


Look for C++, and don't accidentally download C#; that's an entirely different language altogether!
Reply:GCC


http://gcc.gnu.org/
Reply:I personally used Turbo C complier. Its very good for beginners.


You can easily identify the errors during compilation, i am sure you will love it.





You can download it here.


http://www.pitt.edu/~stephenp/misc/downl...


C++, Getting Started?

I'm a computer science graduate and I'd like to start learning C++, I know about a ton of other languages but my university didn't teach it





where would be a good place to start? and is there a runtime environment I need to download?

C++, Getting Started?
%26gt; where would be a good place to start?





Start by getting a decent C++ book. Google also helps. http://accu.org/index.php/book_reviews?u... is a list of book reviews by ACCU, which checks for technical accuracy. I think C++ Primer by Lippman and Accelerated C++ by Koenig are very good choices. If you have plenty of prior programming experience, then Accelerated C++ might be a good choice for you.





Also keep in mind the C++ FAQ http://www.parashift.com/c++-faq-lite/ . And http://forums.devshed.com/c-programming-... which tells you how to deal with some common basic tasks like file opening and string%26lt;-%26gt;numeric conversion. And cppreference.com because you will want to know what the different parts of the standard library are.





%26gt; and is there a runtime environment I need to download?


C++ gets you a native binary for your OS, so you don't need a runtime environment. However, you do need the set of tools to make a C++ binary. They are referred to collectively as the C++ compiler. Microsoft has Visual C++, which runs only on Windows. Otherwise, it is gcc, which is available for linux/*nix, Macs, and Windows (under the name MinGW).





You'll need a C++ compiler. You most likely will want an IDE like Code::Blocks, wxDev-C++, or Visual Studio if you are using Visual C++. Macs have Xcode. Linux have Kdevelop, Anjuta, etc. You could also use a plain text editor in place of an IDE.
Reply:there are many examples available in the tutorial in the editor.


Or go to online tutorials.


Or buy the balagurusamy book for beigneers and The C++ Programming Language. by Bjarne Stroustrup
Reply:surely a CS grad took C and Pascal, so get a Borland C++ compiler and get a good book at B%26amp;N. That plus 24 hrs (SAMS book) should do it. It's not that hard to get started.
Reply:Check this site out http://cpp-home.com. I too am a computer science graduate and this site was very helpful for finding tutorials, example code, and getting answers to questions in their forum while I was in school.


Which is the best book to start learning data structures and algorithms? simple would be best for me!?

I am new to computer field. And I am currently learning C++.


I heard ,it is better to learn algorithms to do better in this field. I started with Introduction to Algorithms


by Thomas H. Cormen, Charles E. Leiserson, and Ronald L. Rivest.





I liked the book. But I found it difficult to understand. Can someone help me out with some simpler book for algorithms.

Which is the best book to start learning data structures and algorithms? simple would be best for me!?
Hi Devi,





Learning algorithms and learning a new programming language are two orthogonal items. But since you are learning both together it would be nice if you could get hold of a Data-structures book that implements algorithms in C++.





Cormen book is supposed to be one of the best books on the subject. Knuth's books on algorithms are also highly regarded. I have personally found Sahni's book "Data Structures, Algorithms and Applications in C++" to be good. I believe that this book is also available as an Indian edition.
Reply:Well programming is a ton of algorithms, but some algorithms in most books are the more advanced type. I always recommend beginners start with a good beginner "syntax" book, then a good "programming practices" book and last a good "learn to debug" book.





The beginner syntax book should be something like a "Sams teach yourself" series or my favorite the visual blueprint series.





The good programming practices/debugging book should be something like McConnells "Code Complete 2" which is the best book on coding practices/debugging I have ever seen.





Then lastly any real debugging book which has simple examples in your language of choice usually works. If you must have a book title, you could try "the science of debugging" by Coriolis publishing. It is an older book and pretty cheap these days, but has some great stories about debugging mishaps and how to prevent bugs.





I have included some titles that you will find the most useful, not only to learn but also as reference later.





Hope they come in handy. Enjoy!

garden state

C++ into WIN32API?

ok, I am learning C++. How come WIN32 API different.

C++ into WIN32API?
One way to look at it is that you can write your own functions in c or c++, right? Well, the Win32 API is functions that Microsoft has written. They're functions that the OS has exposed to you. You don't really care what language they're written in as long as you can make calls to them in the language you want, like c++. OK?
Reply:I believe its because Win32 is written in the programming language called Basic.
Reply:Because C++ is not the Windows API. Windows programming means using prewritten code to control Windows. The API happens to be available in C++, hence you use C++ when using the Windows API. For example, the Twisted APIs (http://twistedmatrix.com/trac/ ) are available in Python, but not C++. Or WinForms in .NET only. Or many of the Java libraries in Java only.


C programming language?

How do you allow spaces when using the scanf() function??





I'm just learning C, and the part of the book I'm in is teaching about scanf(), but when running the program, unless I only use one word it uses the second word for the next scanf()!!!!!





Here is what happens.





What is supposed to happen is.....





Enter an adjective:Fufy


Enter a food:Marshellow


Enter a household chore (Past tence):Cleaned


Enter an item of furniture:Cair








Don't touch that Fufy Marshellow!!


I just Cleaned the Cair!!





Now what it does if two or ree ors are used....





Enter an adjective:Fluffy Marshmellow


Enter a food:Enter a household chore (Past tence):Taking out the trash


Enter an item of furniture:





Don't touch that Fluffy Marshmellow!!


I just Taking the out!!





So how do I allow spaces??

C programming language?
You haven't showed us the actual code that does the reading of the text...





scanf can do lots of things, it depends on how you use it and what you pass to it that controls what it does.





scanf("%s", ...) will I believe read the next white-space delimited string. However, you should never ever use scanf("%s", ...) because you cannot predict how many bytes it will read so you do not know what size buffer to supply.





The problem you have is that your input is terminated by the end of the line, but you have written code that terminates the input on any white space.





To do it correctly, you need to write low level code in a loop that reads input character by character and puts it into a buffer. It should loop until you get a "new line" character, '\n'. You should make sure you don't get buffer overrun, either by reallocating to a bigger buffer or truncating the input when you reach the limit. You will need to nul-terminate your input string so that you can print it out correctly.
Reply:fstream treats spaces as a new word .......... so to allow spaces you need to replace fstream with other statement like getline


C++ linker errors while writing a header file?

Im learning C++, and trying to write a header file called navtools.h which contains the declarations of some useful functions I have written. whenever i compile my "main.cpp", i get lots of errors like





" [Linker error] undefined reference to `CheckValidLat(float)' "





I tried copying another header file from functionx.com (just to see if it worked) and it also compiles with the same errors! can someone help me out?

C++ linker errors while writing a header file?
Here is what you need to do:





main.cpp:





...


#include "navtools.h"


...


CheckValidLat(5.4);


...





In the same folder as main.cpp, you put navtools.h. If you are compiling with MS Visual C++, make sure you add navtools.h to your project.





Remember that #include (and in general any #-directive) literally copies and pastes the referenced file into your .cpp file. So if you don't have the right #include, then it is as if you are using a function that you didn't declare anywhere.
Reply:Hmm i do programm but not in c++ (YET lol) but here are some tips, is the the heder file in the same folder as the rest of the c++ files??? Might it be a syntax erorr??? In the the heder file are all the filenames right??? Well just keep tryin :).
Reply:Seems to me I had similar errors if I included the header file in the build without including the c++ file that had the actual implementation of the method. Try including the obj file from your compiled useful functions as input to the linker.
Reply:Your main.cpp is calling a function CheckValidLat() that takes a float as an argument. The file containing CheckValidLat() needs to be compiled and linked with the main.cpp.





If CheckValidLat() function is already defined in main.cpp then check the data type of the argument being passed to it.


What is data types &its classification in c++?

iam a beginner of c++programming .





i need online tutorial to learn this data types %26amp; its classification





pls tell me suitable website





also if possible expalin about this





suggest good books for learning c++

What is data types %26amp;its classification in c++?
http://www.cppreference.com/data_types.h...

funeral flowers

4 running a c program?

i have dos operating system in my pc %26amp; i am learning c language but programs are not running on my pc. what things do i need to install,answer me in details as i have no idea about c? can i install it from internet? if yes give me website?

4 running a c program?
download turbo c compiler free from internet
Reply:you have to install a compiler...


turbo C++ will be good on DOS.


try googling.. you will get lot of sites giving details... ;)


borland is one of the best compilers...
Reply:install "microsoft visual c++ software"...u will find it in CD library(shop)...u can also search it in the google search and can download for free.....the steps to be followed are given clearly while downloading....just follow the instructions....and finally dont forget to star my answer.....take care ....
Reply:Install the c++ s/w and if ur familiar with dos operating system u can play "c"
Reply:Hey Neha.. dont panic ;) just install turboC++ and then go on doing your code.. alls gonna be fine.. :)


VB.NET or C#?

Hi, I am making a webpage in visual studio.


The sit e will need some functionality such as user name and password and a photo album etc...





My question is


Should I make it with VB or C#


I'm better at VB but am learning C# in college.

VB.NET or C#?
C# was developed to encourage Java and C++ programmers to migrate to .NET. On the other hand most VB.NET programmers used to be VB 6.0 developers.





VB.NET is easier to understand and learn and VB.NET programmers usually have a hard time working with C#. The converse is not true. C# programmers usually manage to work with VB.NET code.





I suggest you learn C# not because it is superior, but because it is more widespread. Learning C# means you will still be able to write VB.NET without difficulties.





PS: There is a myth that states that C# is faster than VB.NET but this is not true. To be more exact, we can say that VB.NET allows you to take actions that might degrade your application performance. Such actions might not be possible to take with C#.
Reply:If you know vb you can go with VB.net.vb.net Sysntax and logic are almost same except OOPS concept.It's easy to create site when compare to C#.
Reply:C#


VB is dumb.
Reply:well if you know vb, then use that since it will be easier.
Reply:as a .net developer using both languages, i would say to use c#, one as you are learning it at college it will also help you learn c# better.





Also c# is a lot stricter with data typeing and casting of data types, as well as if you learn c# it is similar in many ways to java.
Reply:With those two choices, go with C#.





If you want to try something new and cutting edge, try Ruby on Rails. Visual Studio doesn't generate good code. Better to use a cross-platform, standards-compliant, open-source system.





http://www.rubyonrails.org/





It's free.
Reply:c#
Reply:Actually it is the same if you only use it for designing a webpage (Using ASP.NET), but if you want to use it to make a windows application. It is better to use C#. It is more advanced (and harder to learn) but it provides better memory management and manipulation than VB can do.
Reply:Energizeer Is this about you!??


☆★☆ http://www.osoq.com/funstuff/extra/extra...
Reply:I decided to learn c# even though my background is with VBScript.


I think it is a more advanced language, with more functionality and flexibility, and is used more widely.


If you are looking to work in the area then I think you'll get more money and find it easier to find work.
Reply:VB cos its easier lol
Reply:You can use either to implement your client Although I suggest using a N Tier architecture keeping in mind the importance and benefits of having a thin client.