How To Write A simple Program in a

  • Slides: 13
Download presentation
How To Write A simple Program in a computer Paul John Bobadilla III-1

How To Write A simple Program in a computer Paul John Bobadilla III-1

The simply possible program that you can write using C++ would open a command

The simply possible program that you can write using C++ would open a command prompt, and display text. But before you can even start writing a program, there’s one thing that you need to get: a compiler.

A compiler converts your C++ code into assembly language- the language that your operating

A compiler converts your C++ code into assembly language- the language that your operating system can understand. The operating system converts the assembly language into binary, and the action for the program takes place.

Where can I get that compiler? I would suggest the bloodshed DEV C++ compiler.

Where can I get that compiler? I would suggest the bloodshed DEV C++ compiler. Here's a link for the download

Once you download that, you should open it up, and then go to File>

Once you download that, you should open it up, and then go to File> New> Source File. Here’s where you will start writing your program. To start out, I'll give you the entire code for the program, and we'll examine every command in it.

Here's the code: #include <iostream> using namespace std; int main() { cout<<"I have Written

Here's the code: #include <iostream> using namespace std; int main() { cout<<"I have Written my first C++ program!!! "; cin. get(); }

"#include <iostream>" This tells the compiler that the program will use functions in the

"#include <iostream>" This tells the compiler that the program will use functions in the header "iostream. " This may be redundant, but "iostream" is a header for the program. That header includes many different functions that are included in the C++ standard.

-The second important part is the "using namespace std; " This tells the compiler

-The second important part is the "using namespace std; " This tells the compiler that the set of functions in the program are using the standard library (hence std), and the semi colon at the end signifies that the function has ended. All C++ functions have a semi colon at the end of them.

-Next are the braces. The braces signify that a whole command block is to

-Next are the braces. The braces signify that a whole command block is to be executed, and that command block is within the braces. C++ programs may have any number of command blocks in them.

"; ". The cout part can be easily remembered as c, and out- showing

"; ". The cout part can be easily remembered as c, and out- showing that it is writtin in c, and there is to be an output on the screen. The carrots are known as insertion operators, and anything after them inside of quotes will be displayed (anything after them before the semicolon, of course). The part is the function for a new line. Once again, a semi-colon ends the function.

-Finaly, is the "cin. get(); " command. It makes sure that the program stays

-Finaly, is the "cin. get(); " command. It makes sure that the program stays open after completing all of the commands. Without it, the command prompt box would close before you could read the text that is displayed as a result of you coding.

The command keeps the program open until the user hits the enter key. This

The command keeps the program open until the user hits the enter key. This is sort of like the cou’t thing- c, and in. The input in this case is the enter key. Next, is the semi-colon, ending the function. Lastly comes the closing brace, ending the command block, and as that was your only command block, the program has completed.

I hope you Appreciate my interactive presentation! Thank you sir Reluba for giving me

I hope you Appreciate my interactive presentation! Thank you sir Reluba for giving me enough time !