http://www.dittmerdan.net
dittmerdan.net web
learn to code: website navigator



introduction

  
making programs is not easy. i am not going to lie and say it is just to get 
into your panties..  no sir..  i mean mam.. im not here to butter up your nip-
ples sweet cakes..    hrrrm? maybe i could make myself a program to get 
laid. well anyways. lol i am just going to show you where to get a compiler 
for free,  how to compile a program, and what the hell a compiler is..  then 
im going to just show you a look into ( fundamentals ) .. no thats not candy. 
damn it stop eating this page..   go get some skittles or something..   then 
afterwards you can search for c source code,     which is allready built pro-
gram code made by someone else..   so you can learn from there work or 
even use it in your project..  and then im going to link you to sites too learn 
c language and different functions.

 

what is a compiler

  
what is a compiler.. how do i compile..  i think i just compiled myself..  uhh 
go get cleaned up and come back.. ok a compiler is just a program made 
by someone else to put a program together..  all programming languages 
breaks down into binary..     its pretty simple how it works..   you type it out 
using notepad..  you type it using the language you know..  then you use a 
compiler to assemble it.. all computer languages work pretty the much the 
same way.  just a different syntax, but the basic operation is the same type 
it out and then assemble it.  so it does not matter what language you learn. 
some people say visual basic is better..      some people say this is better. 
perl..   etc so i guess its a madder of preference..   it dont madder just get 
out there and learn. the language you type into notepad is sorta like a blue 
print.. telling the compiler what to do. and it builds you a house..

 

getting started

 
ok first im going to need you to download and install a compiler. then come 
back to this page.. here is a good free one.. 
   
  • bloodshed dev c++.

    after you get done downloading the compiler and installing it i would like for you to do this. click start... then run... and type explorer... at the top of windows explorer click tools then click folder options.. click the view tab.. then uncheck hide file extentions.. then click ok and exit all that..

make your first program

 
alrighty you have the compiler installed. its time to make your first program 
are you ready.  good,  great,  wonderfull.   first make a file on your desktop. 
right click in the open on your desktop.   goto new,  then click new text doc-
ument..    a file will appear on your desktop..          ( new text document.txt ) 
rename it to ( hello.cpp )  ok it should ask are you sure you want to change 
the file name.   click yes.  alright.  right click on the new file. goto open with. 
and if notepad is not there click. choose program. then find notepad on list 
and click open. alright notepad should be open now and it should be blank. 
i want you to copy and paste this code into there.   i was going to use hello 
world as the first program. but every c basic book makes that your first pro-
gram. and hello kitty is a cartoon/game so i am left with hello dittmerdan.
 

#include <iostream>
using namespace std;

int main()
{
cout << "hello dittmerdan";
cin.ignore();

return 0;
}
 
 
now click file,    then save on notepad..     and go ahead and close notepad.  
now double click into the file (hello.cpp)  that you created and inserted code 
into..  and the ( dev-c++ ) program should load now.. if it dont just launch the 
program from your start menu..    and click open and find the file..   now you 
should see the coding that you had pasted into the notepad.   now click exe-
cute at the top..  then click compile..    make sure it compiles,  if it dont click 
debug at the top then debug again..   then recompile it... ok now you should 
have hello.exe on the desktop. congratulations you made your first program.  
click on hello.exe on the desktop. ok you just ran your program and it should 
display hello dittmerdan. and you press enter to exit program. the cin.ignore 
is causeing the pause.. aight you made a program.. 


compare sizes

  
aight mines bigger then yours.  ?? uhh oh file sizes. yea i knew that.. ok right 
click on the  hello.cpp  file and click properties you will see its only 102 bytes. 
then right click on the hello.exe and its 570kb.. thats a difference of


hello.cpp 102 bytes

hello.exe 570,000 bytes
 

see why i say a blue print to a house..  something small making something so 
big.  thats because the program is putting system drivers in it and bs and putt-
ing it into binary so the computer can recognize it..

ok that was pretty easy wasent it. but making big complex programs that runs 
in windows.. is alot harder..  but i hope you get the idea from this source.. and 
now you got yourself a good compiler.. ok looking back at the coding you see 
where it says #include you have to include headers for different functions. cout 
is a function to display a message.    cin is a function being used to pause the 
screen. so now you see what a function is..      the file that controls the function 
has to be included in the header and its called a class. a class is just premade 
coding to include in a project. iostream is a class you can also make your own 
class's.    for instance say you make something and   5 programs  in a project 
share the same functions you made.    you dont have to retype it over and over.   
just include the class file. return 0; is a function to make the program end.

a virtual class is a class inside the same document as the function being used
there is an example of this in the fundamentals section.
 

fundamentals


newline this program demonstrates making a new line in a program ( \n )

#include <iostream>
using namespace std;

int main()
{
cout << "hi whats up";
cout << "\n";
cout << "nothing much\n";
cout << "how about you";
cin.ignore();

return 0;
}


variable this program demonstrates what a variable is. ( var )

#include <iostream>
using namespace std;

int main()
{
int var;
var = 20;
cout << var;
cin.ignore();

return 0;
}



keyed input this program demonstrates keyboard input.

#include <iostream>
using namespace std;

int main()
{
cout << "type a number\n";
int input;
cin >> input;
cout << "your number is " << input;
cin.ignore(2);

return 0;
}



numeral operators this program demonstrates numeral operators ( x * + - / )

#include <iostream>
using namespace std;
int main()
{
int a, b, c, d;
int answer;

a = 2;
b = 30;
c = 600;
d = 6;

answer = a * b + c / d - 60;

cout << "the answer is " << answer << "\n";
cin.ignore();

return 0;
}



if statement demonstrates the if statement and other operators ( == > < )

#include <iostream>
using namespace std;

int main()
{
int a, b;
cout << "enter a# ";
cin >> a;

cout << "\n";
cout << "enter b# ";
cin >> b;

cout << "\n";
if(a == b) cout << "a# is equal to b#";
if(a < b) cout << "a# is less then b#";
if(a > b) cout << "a# is greater then b#";
cin.ignore(2);

return 0;
}



goto label demonstrates the goto command sending to a label.

#include <iostream>
using namespace std;

int main()
{
int user1, user2, passcode;

user1 = 1111;
user2 = 2222;

cout << "enter your passcode ";
renter:;
cin >> passcode;
cout << "\n\n";
if(passcode == user1) goto loginu1;
if(passcode == user2) goto loginu2;
cout << "incorrect passcode\n\n";
cout << "please renter ";
goto renter;

loginu1:;
cout << "user 1 is logged in";
cin.ignore(2);
goto end;

loginu2:;
cout << "user 2 is logged in";
cin.ignore(2);
goto end;

end:;
return 0;
}



for loop this program demonstrates the for loop statement

#include <iostream>
using namespace std;

int main()
{
int count;
for(count=1; count <= 99; count=count+1)

cout << "\n";
cout << "count equals " << count << " ";
cin.ignore();

return 0;
}



if else this program demonstrates if else loop statement

#include <iostream>
using namespace std;

int main()
{
int guess, pass;
pass = 1234;

cout << "enter 4 digit passcode: ";
cin >> guess;

if (guess == pass) {
cout << "\n";
cout << "passcode correct: welcome user";
} else {
cout << "\n";
cout << "passcode incorrect: try again";

}
cin.ignore(2);
return 0;
}



the switch this program demonstrates the switch statement

#include <iostream>
using namespace std;

int main()
{
int num;
cout << "enter passcode ";
cin >> num;

switch(num) {
case 1111:
cout << "\n";
cout << "welcome user 1";
break;

case 2222:
cout << "\n";
cout << "welcome user 2";
break;

case 3333:
cout << "\n";
cout << "welcome user 3";
break;

default:
cout << "\n";
cout << "incorrect passcode";
break;
}

cin.ignore(2);
return 0;
}



do while this program demonstrates the do while loop

#include <iostream>
using namespace std;

int main()
{
int pass;

do {
cout << "enter 4 digit passcode: ";
cin >> pass;
} while(pass != 1234);

cout << "\n\n";
cout << "passcode correct: welcome user";
cin.ignore(2);

return 0;
}



continue loop this program demonstrates the continue loop

#include <iostream>
using namespace std;

int main()
{
while(true) {
cout << "enter a number: ";
int anum;
cin >> anum;

if(anum < 0) {
cout << "\n\nnegitive numbers is not allowed\n\n";
continue;
}

cout << "\n\nyour number is: " << anum;
break;
}

cin.ignore(2);
return 0;
}



codeblocks this demonstrates code blocks in a program

#include <iostream>
using namespace std;

int main()
{
int a, b, c, d;

b = 1111;
c = 2222;
d = 3333;

cout << "enter passcode";
cout << "\n";
cin >> a;

if(a == b) {
cout << "welcome user 1";
}

if(a == c) {
cout << "welcome user 2";
}

if(a == d) {
cout << "welcome user 3";
}


if(a < b) {
cout << "wrong passcode";
}

if(a > d) {
cout << "wrong passcode";
}

return 0;
}



captions this program demonstrates captions in your program

// this program demonstrates captions in a program
// or too put who its made by or when it was made
// or too label things so its easyer for you to locate
// anything after the two slashes is a caption

/*

this is also a caption used mainly at top of program

*/

#include <iostream>
using namespace std;

int main()
{
// the cout output function
cout << "captions";

// cin is used to create the pause
cin.ignore();

// return 0 terminates the program
return 0;
}



virtual class this program demonstrates a virtual class & function

#include <iostream>
using namespace std;

class base {
public:
virtual void vfunc() {
cout << "this demonstrated what a virtual class and function is";
}
};

class derived : public base {
public:
void vfunc() {
cout << "this is the derived virtual function"; }
};

int main()
{
base *p, b;
derived d;

cout << "press enter see the base virtual function";
cout << "\n\n";

cin.ignore();
p = &b;
p->vfunc();

cout << "\n\n";
cout << "press enter again to see the derived virtual function";
cout << "\n\n";
cin.ignore();
p = &d;
p->vfunc();

cin.ignore(1);
return 0;
}






datatypes


int, double & float this program demonstrates these three datatypes

#include <iostream>
using namespace std;

int main()
{
int num1, num2, aa;
double num3, num4, bb;
float num5, num6, cc;

cout << "type a number: ";
cin >> num1;
cout << "\ntype a smaller number then first: ";
cin >> num2;

num3 = num1;
num4 = num2;
num5 = num1;
num6 = num2;

cout << "\nnumber 1 divded by number 2 = ";

aa = num1 / num2;
bb = num3 / num4;
cc = num5 / num6;

cout << "\ninteger = " << aa;
cout << "\ndouble = " << bb;
cout << "\nfloat = " << cc;

cin.ignore(2);
return 0;
}


char this program demonstrates the char datatype

#include <iostream>
using namespace std;

int main()
{
char aletter;
cout << "enter a letter: ";
cin >> aletter;
cout << "\n\n" << aletter;

cin.ignore(2);
return 0;
}


string this program demonstrates the string datatype

#include <iostream>
using namespace std;

int main()
{
string aaa;
aaa = "this is a string datatype";
cout << aaa;

cin.ignore();
return 0;
}


bool this program demonstrates the bool datatype

#include <iostream>
using namespace std;

int main()
{
bool frog;
int n1, n2;

cout << "enter first number ";
cin >> n1;
cout << "\nenter second number ";
cin >> n2;

frog = n1 == n2;

cout.setf(cout.boolalpha);
cout << "\n1st number = 2nd number " << "(" << frog << ")";

cin.ignore(2);
return 0;
}




go here to learn more about datatypes. these are important to know to make programs.

here is links to learn c programming. ahh yes there is more to programming then cout and cin.. no really..

linkstoo


learnc++
 
here is some links for free source code. for compileing with your compiler 
you downloaded.. remember find c/c++ source code..
  

linksfor


freesource code

 
here  is a zip file filled with example code for different functions also have a 
demo in there of  a hidden console window.   and all the examples on this 
page is in there ready to be compiled.

uhh yeah you can also search.. for certain program source code or project. or a certain function. theres alot of sites out there too help.. my site is basicly a motivater.. alot of people will read this never making a program before and be wow'd.. others that make programs all the time gonna be like what a pos program for a first one.. ahh well eat my sack.. i wanted it so people can see how it worked inside. if i made the program a mile long all that would have done is made people click off thinking it was too hard for them to compile it.. this is pretty much my whole site.. there is plunty of pages to put every detail to something in it.. but very few thats just there to get you motivated.. there needs to be both me tinks.. this is the very first program i ever made. while learning c++. it has meters to feet. sales tax calculator, etc. its also in the zip file two collums up.

free hit counter


( DittmerDan.net ) © copyright 2007, all rights reserved. goto main - navigation