I was looking through it and In one Day I accomplished to Learn a little Bit?
Code: Select all
#include <cstdlib>
#include <iostream>
#include "string"
#include <iomanip>
using namespace std;
string name ; // defines name as a string like defineing a number but with letters string insteed of int also
int age ;
int main(int argc, char *argv[])
{
cout << "enter your name"<< endl;
getline (cin, name);
cout << "now enter your age" << endl;
cin >> age ;
cout << name << "you are" << age << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Code: Select all
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
int main()// begins a module simmular to def main()
{
double score1=75.5;// double means decimal number int means normal numbers
double score2=89.4;
double score3=10.6;
double average=(score1 + score2 + score3) / 3.0;
double anser = (score1 * score2);
cout << "score1 = 75.5" << endl;
cout << "score2 = 89.4" << endl;
cout << "score3 = 10.6" << endl;
cout << "the average is" << setw(5)<< average << endl ;
cout << endl << endl;
cout << "the anser is" << setw (7) << anser << endl << endl;
cout << setprecision(3) << setw(10) << -3.455 << endl; // this makes it so it shows the first 3 digets and rounds the number
cout << setiosflags(ios::right); // this makes it so it appears spaces after the number not b4 it
cout << " thing " << setw(10) << " thingy" << setw (20)<< endl;// this makes it so i can make a curtain amount of spaces between words
cout << setw(10) << 50 << setw(20) << 100.7687 << endl ; // this prints numbers neatly with 10 spaces between them
printf("hello "); // printf is the print statement and the "hello" is what is typed /n means endline
cout << "this is a test" << endl; // if i dont use namespace std this wont work
system("PAUSE");// makes it so the program doesnt close imediately after its done running
return 0;// ends the program
}
Both of these are working codes.
My overall Question is do i just follow what is in my book will i eventually Be heading in the right Direction?
Will I really need to know all this stuff?
Is my book too old?
Sorry if i sound like a noob But what is the most effective way of learning C++ and all the other shit I need to know to make a Game?
Can i have someone that is experieced Help me out and recomend what i should do?