-
January 4th, 2002, 09:37 PM
#1
Junior Member
Short C++ tutorial ( very short )
Ok this is a very short tutorials on C++, even though i'm only into Arrays right now, I feel I can share my knowledge a tad.
Ok, We will learn how to use a "function" to output text to the monitor.
It can also output
intergers " int " ( -1, -2, -3, -- 1, 2, 3).
float "float" (decimal numbers. 1.0, 2.0, 3.0)
characters "char" ( a, b, c, d, e, f "you call this string too")
and
Doubles " double " These are Floats but with more space.
The stuff in the " " is how you word declare varibales.
Ok, so you want to know how to declare a variable.
varibale, basically a way of allocating memory.
#include <iostream.h> //this is a comment
// ^ don't worry about this yet.
int main() // don't worry about this yet, just studying output.
{ // this tells the complier where the program begins.
char a=A; // declaring the varibale and giveing it a value of A
// always end a statement with a sei-colon ";"
int b = 1; /*declaring the variable b and assigning 1 as it's variable*/
/* This is another form of comments, C style. */
float c = 3.5; // Declaring c and assigning the value of 3.5 to it.
double d=3.1452698 /* declaring the variable d and assigning the value of 3.1452698 to it*/
cout << a << endl; //outputs the value of a to the screen
cout << b << endl; //outputs the value of b to the screen
cout << c << endl; // output the value of c ot he screen
cout << d << endl; //outputs the value of d to the screen
return 0; // terminates the program
} //closing brace
Ok since that looks crowded i'll type the program out without comments. so it looks better
#include <iostream.h>
int main()
{
char a =A;
int b = 1;
float c = 3.5;
double d = 3.1452698;
cout << a << endl;
cout << b << endl;
cout << c << endl;
cout << d<< endl;
return 0;
}
You can have as many whitespaces as you want in C++ ( whitespaces = spaces )
Anyone can add on tot his tutorial. If you want me to add on, reply to this. thanks alot.
-
January 4th, 2002, 09:59 PM
#2
Just a little note is case a newbie does not know what // means.
// has no affect on the program. A programmer makes a // and a statement following it. The statement is information on what the programmer is doing (or trying to do) It is like ummm.. a reminder. AN Example: "if a programmer looks at an old programm he wrote he can look at the // and see what he was doing.
//just a note
[shadow]l3aDmOnKeY[/shadow]
-
January 7th, 2002, 07:17 PM
#3
Junior Member
If anyone wants me to add on to this short tutorial reply or something be glad to.
-
January 7th, 2002, 07:52 PM
#4
Good post dude...keep it up! People like yourself help educate those that don't know or need a bit of a push.
We the willing, led by the unknowing, have been doing the impossible for the ungrateful. We have done so much with so little for so long that we are now qualified to do just about anything with almost nothing.
-
January 7th, 2002, 09:38 PM
#5
Junior Member
C++ tutorial expansion.. Input
Ok, since you should have a basic understanding of Outpu, and got bored with it by now. I will go over basic input.
Bare with me here, I'm busying learning this language and TCP/IP ( and learning more about linux )..
Ok
I gope you remember the comment "//" "/* .... */" . If not look back on them.
#include <iostream.h> // don't worry about this yet.
int main() // or this, lol
{ // opening brace
int a; // our variable that we shall use
cout << " Enter a number to be shown on the screen : \t";
/* the "\t" means TAB, just like "\n" means new line */
cin >> a; // this ask for input by you, to set the value of a
/* notic the differenc between the cout "<<" and the cin ">>", << directs the message to output, and >> recieves the input by you. If i'm wrong onthis please correct me. But it isn't that important as long as you keep them right, and not mix them up */
cout << a << endl; // outputs the value of a
return 0;
} // end of program
remember to end all statements with a semi-colon " ; "
Now I will write the code out with no comments.
#include <iostream.h>
int main()
{
int a;
cout << "Enter a number to be shown on the screen : \t";
cin >> a;
cout << a << endl;
return 0;
}
ok well maybe this will help you all. I must go back to my learning now. If you all would still like some more tutorials, reply.
And remmeber, anyone can add on to this.
Later
MR
-
January 7th, 2002, 10:11 PM
#6
Junior Member
Good post
people who are just starting out on their learning journey really appreciate people like you.
-
January 8th, 2002, 01:37 AM
#7
Junior Member
Thanks, feels.
They can also go to gametutorials.com
if they feel the need to learn more, before I can write another tutorial. It is code heavily commented. If yall' want some links to e-books reply.
Later, cheers.
MR
-
January 11th, 2002, 12:20 PM
#8
Originally posted by Mystic Ravenous
Thanks, feels.
They can also go to gametutorials.com
if they feel the need to learn more, before I can write another tutorial. It is code heavily commented. If yall' want some links to e-books reply.
Later, cheers.
MR
hello mystic...this was really a good post...but u were talking something about some ebooks...if u have any e-books pls send it to me if u can. i will be very grateful to u as i really need them.
i want some books on C++ and driver programming and stuff like that...
can anybody help me...pls...
pls mail me on pok_pok_007@yahoo.com
thank u soo much..
intruder....
-
January 12th, 2002, 03:15 AM
#9
Member
if anybody is intrested in c/c++ programming i'll suggest you visit www.cprogramming.com.
It's a really good site for beginners as well as experts to clear their doubts.
-
January 12th, 2002, 04:53 AM
#10
Junior Member
cprogramming.com
cplusplus.com
1001tutorials.com
functionx
Search Google.com you'll get loads!
for books
Practical C++
Sams C++ 21 days
C++ Primer Plus
C++ for dummies
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|