![]() |
|
#11
|
||||
|
||||
|
#include <iostream> using namespace std; int main() { cout<<"Hello World\n" } |
|
#12
|
||||
|
||||
|
ok a couple of things that I forgot to put in lesson #1
{ = brace cout = display message << = insert operator // = one line of comments /* more than one line of remarks and then */ to close your remarks \n = make a new line \t = tab For example you can have a program like this ------------------------- #include <iostream.h> void main() { // this is how you make a comment /* this is how you make more than one line of comments */ cout<< "Hi there\n"; cout<< "How are you?\n"; } --------------------------- The \n will create a new line for you so the screen will read Hi there How are you? Without the "\n" then the screen would have shown Hi thereHow are you?
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403 Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884 Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694 |
|
#13
|
||||
|
||||
|
Yes that is another way to do it joe88 but I wanted to start off as simple as possible for those who don't have any knowledge of C++ yet. Also you forgot the " ; " after your cout statement
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403 Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884 Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694 |
|
#14
|
||||
|
||||
|
Quote:
the complier would have picked up the error. Guess now its time for cin statments. int main() { int name; cout<<"plese enter your name\n"; cin>>name; cout<<"your name is "<<name<<endl; } |
|
#15
|
||||
|
||||
|
No No No, you are jumping way ahead lol. I haven't even gone over declaring variables yet. Besides, you already made another error. You cant declare name as an interger. It has to be declared as "char" Plus you need to make an array for any name longer then one character. This is how the program would look but everyone else execept joe ignore this for now.
------------------------- #include <iostream> using namespace std; int main() { char name[20]; cout<<"Enter your name:\n"; cin>>name; cout<<"Welcome\t"<<name<<endl; }
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403 Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884 Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694 |
|
#16
|
||||
|
||||
|
I know I should have put char....
But I put int. 1 question : char name[20]; why is there a 20 at the end ? is that the numberes of charaters to store ? |
|
#17
|
||||
|
||||
|
It's called a character array. It is used to store a string of more than one character. "Char" is the data type I used, "name" is the actual array, and [20] is the number of characters you can store into your array. Let me get first get into describing data types and declaring variables before I go too deap into the subject of arrays as probably everyone else here is just getting confused
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403 Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884 Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694 |
|
#18
|
||||
|
||||
|
ok I will go ahead and start with the second lesson so that others can start to catch up to you joe88.
Variables = 1. letters to store data 2. Must be declared before you can use it. Data Types = These are what you use to declare your vaiables. Double - To store number that contain decimal places (23.4453, 7889.00784)(64 bit I believe) Float - Also to store numbers that contain decimal places(2.54, 67.8) (32 bit I believe) Int - To store whole numbers (integers) (1,2,3..) Char - To store characters (A,B,C..) Bool - Ture or false 0=false 1=true. (Almost no one rally uses this data type) Math operations = store + add - subtract * multiply / divide ok now its time for another program. This program will declare two numbers (5,6) as intergers and also declare two numbers as results (sum, product). int num1=5; This means that you are declaring "num1" variable to be an integer type and for it's value to be 5. int sum; This means that you are declaing "sum" variable to be an interger no amtter what is palced inside of it. sum= num1 + num2; This means that whatever the result of adding the two numbers that were stored into num1 and into num2 will be placed into the variable "sum" ---------------------------- #include <iostream> using namespace std; int main() { int num1=5; int num2=6; int sum; int product; sum = num1 + num2; product = num1 * num2; cout<< "Sum = "<<sum<<"\n"; cout<< "Product = "<<product<<"\n"; } --------------------------- After compiling your program, you should get a message on your screen that says Sum = 11 Product = 30 Now you guys should try to make a program that has three numbers (3.5,2.4,7.8) and find the sum, product, and average of all three numbers. As a hint, use "float" or "double" as your data type since now you are using decimals.
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403 Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884 Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694 |
|
#19
|
|||
|
|||
|
This post was posted by me then edited by me. Thus I feel ashamed of my own stuped kitty posts.
|
|
#20
|
|||
|
|||
|
PSPdonkey, you forgot to mention that when declaring CHAR variables with a SINGLE character, you will
have to enclose this variable in double apostrophes ('A'). as opposed to strings which is enclosed in quotes ("EAT"). for example: char initial = 'A'; Very important, can be the source of many bugs!...
__________________
Visit - Illfoundedmind.com production studios, were accepting new members for pspvideo game development. Sparda@illfoundedmind.com |
![]() |
|
|
|||
|
|||
|
|
| Thread Tools | |
| Display Modes | |
|
|