30.8.05

C++ Programming

int main( ){

}

inside the curly braces is the main body of the source code

using Dev C++

printf - name of function to display anything

printf("Hello World"); = this is how printf is used

need to reference the Header File which is included in the program and alerts complier that the proggie uses runtime librarys
you can find the header file by ctrl-click on the function
type it at the begining before main as below...

"/n" is written at the end of the string so that it will write it as a new line...

system("") = is directions for the computer and in the case below it makes it pause in the console window and wait for a key stroke

In order to display Hello World
#include
#include
int main(){
printf("Hello World\n");
system("pause");
}

The above is a Console Application it basically runs within an MSDOS window and has no GUI. The above is from page 61 in the text book.

"cout" is another way of displaying text to a screen but in order to use it one must put
#include
using namespace std;
Before the int main... Like so

#include
#include
#include
using namespace std;
int main(){
printf("Hello World\n");
cout<<"Any message\n";
system("pause");
}

**********************************************************************

int age;

int is a type of variable and age is the name of variable

the three data types are:
  1. int - Integer
  2. float - Float
  3. char - Character

Naming a variable:
Cannot used a reserved word
Spaces cannot be used in a variable name
Identifiers must begin with an uppercase or lower case ASCII letter or underscore
Numbers can be used in an identifier but cannot be the first character
Special characters such as $, &, *, or % cannot be used

to set up a variable with a value
int myVariable = value
Like so below to recall it and print to screen

#include
using namespace std;
int main(){
int Age=21;
cout<< "My ages is ";
cout<< Age;
cout<<>
system("pause");
}

** cout using endl makes it a new line

char Sex='M' ** this si used to display a single character for the variable of Sex



0 Comments:

Post a Comment

<< Home