Jump to content

Welcome to 1Emulation.com
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account
Photo

C++ class

- - - - -

  • Please log in to reply
7 replies to this topic

#1
someboddy

someboddy

    Sergeant Moderator

  • Ultra Members
  • 1,657 posts
  • Gender:Male
  • Location:The Israeli Army
Click to view battle stats
This time, I am going to enter deeper to the programing world, so if you dont understand something, just ask. to program in C++, you will need the compiler. you can download it from here.

#2
Diso

Diso

    Poppy

  • 1Emu Veteran
  • 6,145 posts
  • Gender:Male
  • Location:*points*
Click to view battle stats
Good luck learning it dude!
hope to see some great programs coming out of you

I tried to learn C++ but the guy was like arab so I couldn't understand a word!!!!

#3
someboddy

someboddy

    Sergeant Moderator

  • Ultra Members
  • 1,657 posts
  • Gender:Male
  • Location:The Israeli Army
Click to view battle stats
The first thing you need to know is how to use flowing diagrams. flowing diagrams are sample ways to show the program's guideline. flowing diagrams are written in normal language. for example, lets say we want towrite a program that get's a number, and multipile it by 2. so the flowing diagram goes like this.


Start
|
read number to A
|
put A*2 in A
|
write A
|
End


first, the program start's.
than, the program take a number from the user, and put it on the variable A.
than, the program change A to A*2/
than, the program write A on the screen.
than, the program end's.[/b]

#4
someboddy

someboddy

    Sergeant Moderator

  • Ultra Members
  • 1,657 posts
  • Gender:Male
  • Location:The Israeli Army
Click to view battle stats
This flowing diagram can't actuly multipile's a number, but it can help us to create a program that can.
Type this program to the C++ compiler:

#include <iostream>
using namespace std;

void main(){
int A;
cin >>A;
A=A*2;
cout <<A;
}


now run it (press Ctrl+F9), enter a number, and press Enter. you will return to the editor. In order to see the program results, run the program again. (if you have visual C++, press F5 to run the program)

now I will explain the program:

#include <iostream>
using namespace std;

this part tells the program to use the file "iostream". this file contain's the basic commands you will need. every command in C++(and many another programming languages) must end with ";", so don't forget to put it.

void main(){
this command start's the program's boddy. after the program finish's the "include" part, it goes to the "main" part, and does the command's there. this line doesn't end with ";", becouse it's a function (I will explain about function's in more advance lesson's), and it will only end when it will reach to "}".

int A;
this command creates a new variable from the type integer, and give it the name "A". when we will want to use that variable, we use the name A. integer's are complete numbers, so you can't put fraction's in it.

cin >>A;
the "cin" command take's informatio from the users, and put it in variables. before every variable you want to put data in, you type ">>".

A=A*2;
this command put's the data in the right side ("A*2" in this case), to the variable in the left side ("A").

cout <<A;
the "cout" command print's data on the screen. the data can be variable, phrase, a number or text. before every data you want to print on the screen, you type "<<".

}
in order to end the "main" part (or any another block), you need "}". after the "}", you don't put ";".

#5
alexis

alexis

    Argentina Football Ownz

  • Ultra Members
  • 1,735 posts
  • Location:Somewhere in time
Click to view battle stats
Cool man thnx =D

#6
solidius23

solidius23

    The Cult of Personality

  • Moderator
  • 2,861 posts
  • Gender:Male
  • Location:S.Arkansas
Click to view battle stats
lol i wish i had the time to learn c++

#7
DeathDealer

DeathDealer

    Newbie Poster

  • Members
  • 1 posts
Click to view battle stats
well someboddy good like trying to teach C++

its not really that simple now is it.i dont expect any from here to learn enough to make worthy program

#8
alexis

alexis

    Argentina Football Ownz

  • Ultra Members
  • 1,735 posts
  • Location:Somewhere in time
Click to view battle stats
thnx for the confidence dude




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users