How to create program in C++ using Dev-C++
01. Create a new folder in "My Documents" to save your programs.02. Name that folder. For example, "My C++ Programs" or whatever you like.
03. Start Dev-C++.
04. Click on file ->new->Source File.
05. Click on file -> Save As.
06. Select the destination to save your file.
07. Give the file name and save it on the folder that you created for it.
08. Type your source code.
09. To compile and run both with single key press F9.
10. If you type your source code properly, your program will execute, otherwise it will show error.
11. If your program shows error, then see your source code carefully, identify the errors and correct it.
12. After correcting your source code, you to have compile and run it again. Press F9 again to compile and run.
Please do comment if you don't understand any part or want to know more or just want to say thanks. I love programming and love to teach my friends. Your suggestions and appreciation will make this blog much better.
Want to learn more? View List Of All Chapters
After struggling to figure all of this out on my own as an introductory cpmsci student..this made life simple. Thank you.
ReplyDeleteYou are welcome!!
ReplyDeleteThanks Mohammed Homam
ReplyDeleteThis is an amazing tutorial, thank you for going through all the tiny steps! I'm so excited to keep going through all of the chapters and improving!
ReplyDeletethanks a lot man !! nice work..
ReplyDeletei have a problem.. i wrote a code , it is compiling .. it is executing also .. i.e. the black window appears and prompts to enter the value , but result is not displayed.. as soon as i type a value and press enter , the window closes .. its a simple program wherein the value of a is entered and b=a+5 is displayed .. i have just started learning ..
To hold the output, you can use either cin.get(); or getch(); or system("PAUSE"); before the return 0; statement.
ReplyDeleteIf this doesn't solve your problem then paste your code here, so I could understand exactly what the problem is.
thanks man .. system("pause") solved the problem .. for the other commands , it said that the function undeclared blah blah ..please explain what needs to be done ti use getch() and other commands .. thankyou
ReplyDeleteYou can use getch(); funtion if you add the header file <conio.h>
ReplyDeleteBut it is recommended not to use it, as it is the compiler extension and not a part of standard c++.
Also avoid using system("PAUSE"); as it is not portable. It works only on those OS that supports PAUSE command like DOS and Windows but not on LINUX and others.
You can use cin.get(); function, but for that you have to add "using std::cin;" or "using namespace std;"
This is part of c++ standard. Use cin.get() and avoid getch(); and system("PAUSE");
But this cin.get(); does not work exactly like getch() or system("PAUSE"); When you type the character it is displayed in the screen.
This can also be solved if you use better IDE like: CodeBlocks or VC++
Download CodeBlocks
Download Visual C++ Express
In CodeBlocks and VC++ you don't need to write any code for holding the output, the compiler will do that for you. Also the developement for Dev-C++ has been stopped, meaning if there is any bug, it wont get fixed, so better not use Dev-C++ and use either CodeBlocks or VC++ whichever you feel better. Both are good.
thanks man !!i really appreciate your initiative to teach c++ so interactively .. !!
ReplyDeleteThanks for these lessons! They're very helpful.
ReplyDeletepls, send me an examples of dev-c++ program.
ReplyDeleteSee the list of all chapters:
DeleteList Of All Chapters
All these will work on dev-c++. Just add system("PAUSE"); before the return 0; statement.
In dev-c++, just press F9 to compile and run.
pls, send me an examples of dev-c++ program.
ReplyDeleteYour blog is extremely brilliant especially the quality content is really appreciable.
ReplyDeletec++ programming tutorial
nice article for beginners.thank you.
ReplyDeletewelookups C++
javacodegeeks