PDA

Click to See Complete Forum and Search --> : Short C++ tutorial ( very short )


Mystic Ravenous
January 4th, 2002, 07:37 PM
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.

l3aDmOnKeY
January 4th, 2002, 07:59 PM
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

Mystic Ravenous
January 7th, 2002, 05:17 PM
If anyone wants me to add on to this short tutorial reply or something be glad to.

Vorlin
January 7th, 2002, 05:52 PM
Good post dude...keep it up! People like yourself help educate those that don't know or need a bit of a push. :D

Mystic Ravenous
January 7th, 2002, 07:38 PM
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

brownbomber
January 7th, 2002, 08:11 PM
people who are just starting out on their learning journey really appreciate people like you.

Mystic Ravenous
January 7th, 2002, 11:37 PM
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

intruder
January 11th, 2002, 10:20 AM
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....

ihsir
January 12th, 2002, 01:15 AM
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.:cool:

Mystic Ravenous
January 12th, 2002, 02:53 AM
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

intruder
January 12th, 2002, 04:59 AM
Originally posted by Mystic Ravenous
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
thank u very much for the information mystic..but can u give me some
links from where i can download some free good e-books on C C++ and
assembly...pls help...

thank u

intruder..

Mystic Ravenous
January 12th, 2002, 11:19 PM
I'm not sure about d/l, search google, but...

www.viet-learn.com


Has a crap load of them.. ( very good too )..

I would recommend getting some books.




cheers,

MR

hot_ice
January 13th, 2002, 02:53 PM
Great tutorial Mystic Ravenous, you inspired me to do a java one, just one correction I want to make (I think) for the first tutorial. When I ran the program, it spat out 31 errors, so I fiddled around with it and finally got it working - the only thing I changed is when you initialize the char a = A, I changed to char a = 'A' and it worked.

I really have no idea with C, so maybe it's my compiler or something, but that worked for me (I'm using BloodShed Dev-C++).

Anyways, Great stuff, keep it all going...I'm gonna try the second one...

Thanks,
Greg

Mystic Ravenous
January 13th, 2002, 04:56 PM
Ops, sorry. I got the the ' ' .. Thanks..I try to get people into programing more.

MR