#include %26lt;iostream%26gt;
int add(int x, int y)
{
return x + y + x;
}
int main()
{
int x = 3;
int y = 5;
using namespace std;
cout %26lt;%26lt; "The sum of 3 plus 5 plus 3 is: " %26lt;%26lt; add(3, add(3, 5)) %26lt;%26lt; endl;
return 0;
}
I want it to give me the answer 11. 3 + 5 + 3. What did I do wrong. C++. Visual C++ 2008 Express. It tells me the answer is 17???
Can someone fix this code, or tell me what is wrong in simple terms and what to do?
dude. Look at your return statement : x + y + x
so ...
add(3, add(3, 5)) =
add(3, 3 + 5 + 3) =
add(3, 11) = 3 + 11 + 3 = 17
Software always does exactly what you tell it to do...
Reply:Your add function is incorrect. It should just return:
return x + y;
That should do it.
Reply:Well look at the code...
add(3, add(3, 5))
The inside call is executed first: add(3,5) which will return 3+5+3 = 11. Then you're calling add(3,11), which adds 3+11+3 = 17.
If you want it to just add 3+5+3, then just have a single call to the add function: add(3,5). Or change your add function to return just x+y.
birthday flowers
Sunday, July 26, 2009
How to make a win32 exe from visual basic?
Does any one know how to make a win32 executable using visual studio express edition. I have already downloaded the PSDK from microsoft. And there is sum info for C++ but nuthing for visual basic...
How to make a win32 exe from visual basic?
You can't ! Visual basic is not meant to do win32 applications they all are GUI applications that's the purpose of every software with VISUAL before it's name...
Try using C\C++ for win32 applications
Reply:Visual Basic.NET only makes managed code applications. While you can gain access to unmanaged libraries through COM, you cannot compile VB.Net to unmanaged code. Only .NET output is possible.
Visual C++ Express can produce unmanaged output, if you download the win32 sdk.
Reply:Its pretty simple, once you have written your program just compile it and create the exe file, you should find this option under the file menu
Reply:That's so easy, after creating forms and other parts of your program , follow this Build %26gt; Publish ( Your project name) , this will make an executable file for you, enjoy it.
Reply:Doesn't Visual Studio Express Edition come in different flavors, each supporting a different language? Maybe you downloaded the wrong (C++) version? See my source list:
How to make a win32 exe from visual basic?
You can't ! Visual basic is not meant to do win32 applications they all are GUI applications that's the purpose of every software with VISUAL before it's name...
Try using C\C++ for win32 applications
Reply:Visual Basic.NET only makes managed code applications. While you can gain access to unmanaged libraries through COM, you cannot compile VB.Net to unmanaged code. Only .NET output is possible.
Visual C++ Express can produce unmanaged output, if you download the win32 sdk.
Reply:Its pretty simple, once you have written your program just compile it and create the exe file, you should find this option under the file menu
Reply:That's so easy, after creating forms and other parts of your program , follow this Build %26gt; Publish ( Your project name) , this will make an executable file for you, enjoy it.
Reply:Doesn't Visual Studio Express Edition come in different flavors, each supporting a different language? Maybe you downloaded the wrong (C++) version? See my source list:
How can I make my application copy an .exe into a folder?
Im using Microsft Visual C++ 2005 Express Edition and I would like to know how I can make one application copy a previously made .exe application into a folder (e.g. C:/Program Files/MSN Messenger/)
Can I do this and if so how, please give code or a direct link to a relevant page and not a whole website.
How can I make my application copy an .exe into a folder?
look for "system" in the VC++ help:
#include %26lt;process.h%26gt;
void main( void )
{
system( "cp c:\filename.txt c:\somewhere\filename.txt" );
}
this uses DOS style commands, in this case "cp" for copy etc...you will need to look up other DOS command prompt commands for other shell activity using system()
Can I do this and if so how, please give code or a direct link to a relevant page and not a whole website.
How can I make my application copy an .exe into a folder?
look for "system" in the VC++ help:
#include %26lt;process.h%26gt;
void main( void )
{
system( "cp c:\filename.txt c:\somewhere\filename.txt" );
}
this uses DOS style commands, in this case "cp" for copy etc...you will need to look up other DOS command prompt commands for other shell activity using system()
How do I create this?
Im new to C++ computer programming and wondered how to create a simple program that just displays some text and maybe a link. Just like a (warning) pop up you get but bigger.
Can anyone help me on this?
Please post the code for it or give a link
Im using Microsoft Visual C++ 2005 Express Edition
How do I create this?
you want to create a message box. try this code:
#include %26lt;windows.h%26gt;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
MessageBox (NULL, "Hello World" , "Hello", 0);
return 0;
}
Reply:http://www.good-tutorials.com/
http://www.digitaljuice.com/
http://www.tutorialkit.com/
http://www.codestyles.com/
http://www.sitecube.com/website/promo_bw...
Can anyone help me on this?
Please post the code for it or give a link
Im using Microsoft Visual C++ 2005 Express Edition
How do I create this?
you want to create a message box. try this code:
#include %26lt;windows.h%26gt;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
MessageBox (NULL, "Hello World" , "Hello", 0);
return 0;
}
Reply:http://www.good-tutorials.com/
http://www.digitaljuice.com/
http://www.tutorialkit.com/
http://www.codestyles.com/
http://www.sitecube.com/website/promo_bw...
About Path Error?
I am a student learning assembly language usin Microsoft Visual c++ 2005 express addition. We installed program to default location and then download Irvine examples files to C:\Irvine which is to be the path for using ,storing the files however after the build of file is complete the software will not run Says can't start program the file can not be found it also will not run any of the sample programs . My teacher and I have gone over the setup and can not locate a problem. Does any one have a suggestion as to how I can resolve this issue.
About Path Error?
This maybe the Microsoft rules for this, only Microsoft built software program can be executed at root directory level. Try to get your project directory under your desktop. The software you built should run from there.
florist delivery
About Path Error?
This maybe the Microsoft rules for this, only Microsoft built software program can be executed at root directory level. Try to get your project directory under your desktop. The software you built should run from there.
florist delivery
How do I link a .cpp to a .obj?
I created and compiled a C++ program in Microsoft Visual C++ 2008 Express. I have both the .cpp and the .obj and I want to make it a .exe to run it. So can I do this with Viusal C++ or do I write another program?
How do I link a .cpp to a .obj?
In VS go to the build options. In the options, set the build to "release" and not debug. The next time you build, it'll make an ".exe" file for you in the \release folder.
How do I link a .cpp to a .obj?
In VS go to the build options. In the options, set the build to "release" and not debug. The next time you build, it'll make an ".exe" file for you in the \release folder.
I'm looking for a good Web Designer in Dublin to help me set up my eCommerce site & teach me some Tech detail
I am looking for someone who has some background in 'Microsoft Visual C# 2005 Express Edition' and 'Microsoft Visual Web Developer 2005 Express Edition' and 'SQL Server Business Intelligence Development Studio'. I don't just want a Web site built - its important i can learn this process so i can develop the skill %26amp; know-how to mantain the site and add to it myself.
So i need to get lessons as well !
Dont have a big budget - so cant spend to much on this.
Keen to learn - and I enjoy this side of computers.
I'm looking for a good Web Designer in Dublin to help me set up my eCommerce site %26amp; teach me some Tech detail
I know someone that works near Dublin that designs websites and works for a company in that field, he is always looking for challenges and extra work... so he might just help at least point you in the right direction. send me your address and your request to geraldr@saol.com and I will first see if he is interested before I just send a stranger along to his mail address... **** luck!
Reply:contact any local consultant.now a days so many wen programmers are available at lower rates
So i need to get lessons as well !
Dont have a big budget - so cant spend to much on this.
Keen to learn - and I enjoy this side of computers.
I'm looking for a good Web Designer in Dublin to help me set up my eCommerce site %26amp; teach me some Tech detail
I know someone that works near Dublin that designs websites and works for a company in that field, he is always looking for challenges and extra work... so he might just help at least point you in the right direction. send me your address and your request to geraldr@saol.com and I will first see if he is interested before I just send a stranger along to his mail address... **** luck!
Reply:contact any local consultant.now a days so many wen programmers are available at lower rates
Subscribe to:
Posts (Atom)