Okay, well today I've started learning C++ and after about 30 minutes I've managed to compile my first program
All it does is prompt you to type a number in between 1 and 10. If it's not in that range, it adds/subtracts until it is. The best part is you get to see it add/subtract the numbers up one-by-one!
Code:
CODE
#include <iostream>
using namespace std;
int main() {
// Define variables
int anumber;
cout<<"Please enter a number between 1 and 10"; cin>> anumber; cin.ignore();
if (anumber > 10) {
cout<<"\nNumber above 10!\n\n";
} else if (anumber < 1) {
cout<<"\nNumber below 1!\n\n";
} else {
cout<<"\nYou entered "<< anumber <<" which is between 1 and 10\n\n";
Okay, well today I've started learning C++ and after about 30 minutes I've managed to compile my first program
All it does is prompt you to type a number in between 1 and 10. If it's not in that range, it adds/subtracts until it is. The best part is you get to see it add/subtract the numbers up one-by-one!
Code:
CODE
#include <iostream>
using namespace std;
int main() {
// Define variables
int anumber;
cout<<"Please enter a number between 1 and 10"; cin>> anumber; cin.ignore();
if (anumber > 10) {
cout<<"\nNumber above 10!\n\n";
} else if (anumber < 1) {
cout<<"\nNumber below 1!\n\n";
} else {
cout<<"\nYou entered "<< anumber <<" which is between 1 and 10\n\n";
Let me join discussing this topic and add continuation to this thread. C++ is an easy language to learn. And it is true that programming is often considered to be an art. The idea of efficient programming is to master the logic flow and designing according to th requirement of the problem or client.C++ is a structured language which is a super set of the C language. Many new features are added to the classical C to evolve itself into C++. To learn C++ or any other programming language one must master logic flow concept and the basics of the programming language syntax.Be it C++ or Java or PHP programming is never difficult. to learn concept of structured language C++ is a good start while C is the classical procedural language.
electriic ink: You posted this topic a while ago, so you're a bit more in C++ by now, I think. But there is a little thing that's itching me to correct:
Just in order to be more elegant, you should use instead of this:
QUOTE
for (int a = anumber; a > 10; a--) { cout<< a <<"\n"; } cout<<"10\n\n";
this:
QUOTE
for (int a = anumber; a >= 10; a--) { cout<< a <<"\n"; }
That way, you don't have to put that cout-line. It's the easiest way to interpret for if the standard definition looks like:
I agree with kl223. It is just a better practice. Also, about ur comment about how c++ is easier to learn than php, they are very similar. PHP just added a few features that make it easier to interact with a database and such that make it seem harder. However, if you know one, you will be fine programming in the other. Also, once you know one language that is a higher level language like C++ or Java, it is very easy to use the other one since all the concepts are the same just different words and a few other syntax differences.
I agree with kl223. It is just a better practice. Also, about ur comment about how c++ is easier to learn than php, they are very similar. PHP just added a few features that make it easier to interact with a database and such that make it seem harder. However, if you know one, you will be fine programming in the other. Also, once you know one language that is a higher level language like C++ or Java, it is very easy to use the other one since all the concepts are the same just different words and a few other syntax differences.
It IS true that you can learn a programming language after you know another one. However, there are significant differences beetween C++ and PHP. I would say, basically the only similarity is that both are able to access network.
PHP is a script-language. Being it, it's interpreted instead of compiled. That means, you'll never see the binary from the php source you've written. It also has the usual improvements that a normal script-language does. For example: no need for explicit variable type declaration; runtime evaluation of a string into code; easily written self-modifier programs; etc. It's meant to be a server-side scripting language that uses databases/etc and generates HTML output for the user. Of course there are other ways of use PHP, too. There are for example bittorrent trackers written in PHP or there is a way to use php as a client-side script, just like bash, python, perl, etc.
In the opposite, C++ is a precompiled-language. That means, you cannot do anything more with the source than to compile 'em. In C++, every variable has its own well-defined type, and it cannot be changed during the execution of the program. It is also capable of getting used as server-side CGI script, but it's not that popular. Not even that supported, either. C++ is alot faster in most cases and it is just like C or Java. It's not similar to a scripting language.
So, I believe C++ cannot help too much more in PHP programming than any other programming language. (ps: even if it's not true the other way around. Since php is written in C/C++, you can look into the source of the php interpreter and copy-paste functions if you like. Some of them are really interesting. )
Good work for a beginner Any way you was able to put each procedures running in 2 if() conditions having the same condition int the same if() *And there is a word replacing "\n" in the C++ language which is : endl = End line . I think it is easier to be read . *Why don't you replace :
CODE
cin.get();
by
CODE
system("PAUSE");
which shows you a beautiful line in the console
QUOTE
("Press any key to continue")
*Always return a 0 status from you program , in fact i always use :
CODE
return EXIT_SUCCESS
which means that the program encountered no problem .
->After modifications you code will be like this : (Your actual code is correct but it will be more ... Professional ? )
CODE
#include
using namespace std;
int main() {
[indent]// Define variables int anumber;
cout<<"Please enter a number between 1 and 10"; cin>> anumber; cout<
if (anumber > 10) {
[indent]cout<<"Number above 10!"; cout<<< endl;
cout<<"Decreasing number entered to 10...."; cout<<< endl;
for (int a = anumber; a >= 10; a--) {
[indent]cout<< a <<endl; [/indent] }
[/indent]} else if (anumber < 1) {
[indent]cout<<"Number below 1!"; cout<<< endl;
cout<<"Increasing number entered to 1...."; cout<<< endl;
for (int b = anumber; b <= 1; b++) { [indent]cout<< b <<endl; [/indent]}
[/indent]} else {
[indent]cout<<"You entered "<< anumber <<" which is between 1 and 10"; cout<<< endl; [/indent]} cout<<< endl;
system("PAUSE"); return EXIT_SUCCESS; [/indent] }
Now what do you think ?
Notice from rvalkass:
Your code needs to have Code tags around it. Added them.
By basic, i mean reaaaal "BASIC". I know that its probably redundant info for so many of us, but I
still would like you to add your bit into this post , so that newbies benefit from it.....
I'm trying to join my videos all together, I want to make overlay or I don't know what's
it's supposed to call, but I do have some examples. Please take a look at this link
http://www.youtube.com/watch?v=oMqGADSqcZ8 It's for example, take a look at 00.50. The author
joined Morgan Freeman's video with another video. Or take a look at this too
http://www.youtube.com/watch?v=Bsjd7fVJQy0 at 03.19, 03.36. At 03.36, when pyro (the blue man
dancing), there's another video added, another man called G-Man dancing too. What software
needed to crea....
Hi I am currently running a Joomla CMS webpage, and Google Adsense on my page has generated a
reasonable sum. I have used Joomla to build this webpage at the grounding and now with all the
extension, it has become a money making webpage. I encourage all to try out this great CMS system.
Here are some extentions I would reccomend. CB Bulider. Expose 4, Jambook, Ako Comment. Cheers.....
Ever forget what the program is? My friend made this list a while back at another forum and I have
had it on another forum sitting there, maybe you will get some use from it. QUOTE 3D
Graphics: 3Delight Free - http://www.3delight.com/index.htm Anim8or - http://www.anim8or.com/
Blender - http://www.blender3d.org/ gmax - http://www.discreet.com/products/gmax/ Houdini
(Free Edition) - http://www.sidefx.com/apprentice/index.html Now3D -
http://digilander.libero.it/giulios/Eng/homepage.htm OpenFX - http://www.openfx.org POV-Ray -
http://www.povra....
Alright, i am working on a website where a number of different users from different companies will
be looking hooking into one website. What i want is to know how i can differentiate between the
users based on the information passed by the webserver. I've been told to that information
will be passed along html_user(and if i have a distinct user then i can just query the database with
that info and get what i want) But how does this work? I am sorry i know this is cryptic i'm
kind of searching to see if this strikes a bell with anyone. So to sum, many user....
Ok, I'm not sure if I can say this with a straight face, so I'll just say for you poor
college students who need some extra green for that weekend movie (Mike, you reading this?), you
might check in to this more closely. You never know, some of your relatives down the line might
actually be able to say, with honesty, "Well, I'm a monkey's Uncle!" I guess some
perverts are wanting your "seed" so they can create the ultimate, uh.... Well, someone help me out
here: THE LINK Horror? Nightmare? Improvement? SIN? Here's the original article in case....
Description Learn how to create a neat-o Game in TI Basic. Its basic premise is that someone
picks a number, then they pass the calculator to their friend, and they try to guess the number.
Once the successfully guess the number a message appears and says that they have won. I have also
included a line that keeps users from choosing numbers greater than one-hundred. Please Enjoy.
Try I Out Alright.... just input what you see below and I'll explain it a little below.
CODE :ClrHome :Lbl 2 :Prompt A :A->X :If X>100 :Goto 2 ....
Description Ok, so this is my first TI-BASIC tutorial. In this tutorial you will learn how to
create a very simple slot machine, so you can entertain yourself in math class /tongue.gif"
style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> You will need at least a TI
83 Calculator. Try it out Ok, first create a new program called 'SLOT MACHINE'. Hit the
enter key. Now input the following code. CODE :ClrHome :Lbl 1
:Output(1,1,"--Slot Machine--") :Output(2,1,randInt(0,9,1))
:Output....
Symptoms of Cancer 1. Lumps, especially those that are growing larger gradually, appearing on parts
of your body such as the breasts, neck abdomen. 2. Signs of injury not externally inflicted which
do not go away after a long time, such as bruises and scratches on the skin or ulcers on the tongue
3. Body weight keeps fluctuating or nutrition level decreases dramatically (e.g. falling sick more
frequently or feel tired easily) despite the absence of sicknesses that also cause such symptoms
such as Diabetes. 4. Dry cough that does not heal in a long while, blood in phl....
i try to start this topic in webhost category but it seems like i cant. i dont have the permission
so i just post my topic here. im sorry mod.. i want to build a website which contains: - Links to
videos - Informations - photos - flash i don't know if i should use php or just HTML. guys,
what are your opinions..??....
Learning Russia Lesson 1 - Basic Words ~~~~~~ Hello - privyet (informal hello) Hello - zdrastye
(formal hello) Bye - poka How are you - kak dila Good/Wll - horosho Ok/Normal - normalno Poor/Bad -
Ploka ---More Words Yet To Come--- ---Study Makes Perfect--- I am going to make a quiz over this
so you all better be ready =). I hope I inspire you to learn russian. Its a great language plus I am
russian as a russian respects mother russia we respect all so I am sharing top language (not really
top) to you. L = Lesson Quiz - Over L1 http://www.quizyourfriends.com/quizp....
Click the banner to join Referals are strictly prohibited. Posting disabled for 7 days
(Reason: First post is advertising, hence I have a reason to believe that the user is registering
for the sole purpose of advertising.) ....
Alright well I made this program about 3 weeks ago during Spring Break and decided to let you all
test it. It is a program that you can type in questions you would like it to ask and the answers
that go along with them. You have to tell it how many questions there should be before you type
them in. After you are done typing them in you can edit them if you would like or just save and run
them, you can't edit them after you say no. There are two modes for it, Exact Answer and
Typical; if you go Exact Answer you have to have in the exact answer letter for letter a....
Yesterday I suddenly got a lot of work. The same work we try to push off, yes you are right all
formalities to get the code review incorporated and update all source code files with code review
headers. Imagine if you need to open 300 files one by one and append code review headers at the
end. Since most files are reviewed in groups of 20 to 30 files. We require one header to be placed
in say 20 to 30 files. To simplify I went back to my class assignment days and wrote this small c
utility to open all files passed on command line and open attach code review headers an....
Hello everyone, I need help, I need to know which function , or a user defined one should i use to
call a exe from within a program, Like i use switch cases , it certain condition is encountered the
exe should gets executed, that is what i want to do, I am making an operating system for my projects
at university, I need that thing. So somebody please help me, This is the forum that lets me find
all my solutions. I have a 100% problem solution rate here, everyone has helped me alot, Waiting for
some one to post a reply.....
This is a simple and specific tutorial on how to make a basic web browser in Visual Basic 6. Steps
1-3 Create a new project, and then go to "Project" on the menu. Click components as shown in the
following image. Find the component "Microsoft Internet Controls," check it, and click "Apply" and
then "Close." Click the icon that was just added in the tools window, and draw a large sized
window with it. This is going to be where you view webpages through your browser, so don't make
it small, but leave room for buttons and other accessories. Steps 4-6 Make a t....
I need help with Visual Basic 6.0 and adding lines to a textbox without deleting any previous
lines.. I've gotten as far as finding a way to add the lines, but it deletes the prevous entree.
Help is appreciated!....
ARE YOU IN SEARCH OF FREE GOOGLE CASH PROGRAM ? FREE GOOGLE CASH / GOOGLE PROFIT E BOOK
QUOTE This is a free google cash program starter guide (in form of E book) brings you the
step to step process. Discussing about google ad words concepts, choosing the right platform to
reduce your work burden and makes it fully automatic of all. It takes only 20 to 30 minutes to set
an account. Getting the right advertiser based on some important points (EPC rates) so that you can
earn just place ads on google ad words. Ok rest all in guide. About the program Th....
I asked, earlier, about a gfx program that wasn't too simple or too complicated. I tried
downloading the photoshop CS2 trial but for some reason my computer won't open it. I'm
wondering if this computer ( it's not actually mine ) already has a gfx program installed on
it. I don't think it does. There is something called photo impression 5 but I think it's
for the scanner. Are there any other free programs I can download?....
Could someone please tell me what is the most fastest and easiest program to use. I would also like
to know how implement such a banner exchange program on my website....
hi friends, Have a look at the following code... Can u guess what this wud do... nope... no virus
nor executable code... It is a completely valid and compilable C program... dont worry.. I have
executed it on my system and it perfectly nice program /smile.gif' border='0'
style='vertical-align:middle' alt='smile.gif' /> CODE #include <stdio.h>
main(t,_,a) char *a; {return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94,
-27+t, a )&&t == ....
This example will "minimize" your program to the system tray when you click on a button, and restore
it when you click the system tray icon. For this example you'll need: 1 Form - Form1 1 button -
Command1 Add a Module to your project, and ad this code: CODE ' Create an Icon in System
Tray Needs Public Type NOTIFYICONDATA cbSize As Long hwnd As Long uId As Long uFlags As Long
uCallBackMessage As Long hIcon As Long szTip As String * 64 End Type Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1 Public Const NIM_DELETE = &H2 Public Const WM_MOUSEMOVE ....
This tutorial applies to all those people who insist upon using "End" to close their programs: End
stops the program immediately without any thought as to what's going on - it's like a high
speed train hitting a brick wall. It can cause unwanted errors and is bad programming practice in
general. END gets rids of the form, but NOT its leftovers. This leaves a bunch of memory that will
still be in use even after your program has supposedly closed. An object or variable won't be
terminated properly - it's just not a graceful exit. The only time that it'....
ok, i am learning python, and i realy dont know much. my guide im using said to make a program
where it asks your name, and if the name is yours your make it so there is a compliment, if it is
another name you make it that its an insult, and anything else makes it say Nice name. here is what
i wrote name = raw_input("What is your name?") if name == John: print "Your name is freaking
sweet, you must be a god or something." elif name == Bob: print "You have a freakin' weird
name, dude." else: print "Nice name,",name i donot understand what i am doing w....
Some of the installables in java comes in form of .jar file, one has to just double click or type
"java -jar file.jar", and it starts executing. The reason for this is a line appended in the
MANIFEST.MF file of that jar file. For writing a similar jar file of your own, just write your java
file, then compile the same and create a jar file. Create a MANIFEST.MF file and the content should
have the followings: CODE Manifest-Version: 1.0 Created-By: xyz Main-Class:
xyz.MainClass Here xyz.MainClass is the main class. Now create a jar file with the man....
I has use a lot all of macromedia suit like Dreamweaver ultradev4 , 4 , mx , mx2004. Is there
another good program to design website than macromedia dreamweaver? I just want to try other
software may be I will get a new idea and effect for my site. PS. don't try 2 answer microsoft
frontpage hehehe /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> ....
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE
forum, Create your own topics, Ask Questions, track topics, setup
subscriptions & notifications and Get a Free Website w/ Email and FTP.