SlideShare a Scribd company logo
1 of 7
Download to read offline
Getting Set Up - C++ Compilers

The first thing you need to do, before starting on the C + +, is to ensure that you have a compiler. What
compiler, you ask? A compiler converts a program you write to an executable that your computer iscan
correctly understand and execute. If you take the course, you may have one administered through your
school. If you start out on your own, your best bet is to use Code :: Blocks with MinGW. If you are on
Linux,You can use g + +, and if you are on Mac OS X, you can use Xcode


Intro to the C++ Language

A C + + program is a collection of commands that tell the computer to do "something". Collection of
orders is usually called C + + source code, source code or just the code. A good command "function" or
"keyword". Keyword is a block basic building blocks of language, while the function is, in fact, usually
written in the form of simple functions - you'll see this in our first program, below. ? (Confused Think of
it less as a framework for a books; line may indicate each chapter in this book, each chapter may have its
own line, made up of sections each section may have its own line, or it may have all. written details)
Happily., C + + provides the functionality of the general and the keywords you can use.

But how does a program actually begin? Each program in C + + has a function, is always named main,
which is always called when your program first starts up. Of the primary, you can also call the function-
other functions if they were written by us or, as mentioned earlier, provided by the compiler.

So how do you get access to prewritten functions? To access the functions that come standard with
compiler, you include a header with the directive # include. What this does is effectively take everything
in the header and paste it into your program. Let's look at the work program:


                 #include <iostream>
                 using namespace std;

                 int main()
                 {
                   cout<<"Qrembiezs Intruder was here!n";
                   cin.get();
                 }


Let's take a look at the elements of the program. The # include is a "preprocessor" directive that tells the
compiler to put the code in the header called iostream into our program before actually making the
executable. by including header file, you get access to different functions. For example, the function
requires iostream court. Follow include the statement, "using namespace std; '. This line tells the
compiler to use the group functions is part of the standard library (std). By including this line at the top
of the file, you allow the program to using functions like a court. The semicolon is part of the syntax of C
+ +. This tells the compiler that you at the end of the command. You will see later that the semicolon is
used to end most commands in C + +.
The next important line is int main (). This line tells the compiler that a function called main, and that
function returns an integer, hence int. The "curly braces" ({and}) signal the beginning and end of the
function and other code blocks. You can think of them as the meaning of BEGIN and END.
The next line of the program may seem strange. If you have programmed in other languages, you may
wish to print will be a function used to display text. In C + +, however, the courts are used for object
display text (pronounced "C out").

It uses the << symbols, known as "insertion operator", to show what is the output. cout << result in the
function call with the following text as an argument to the function. citing informed compiler that you
want to output a string literal is. The sequence ' n' is actually treated as a single character
stands for a new line (we'll discuss this in more detail later). This moves the cursor on your screen to the
line next. Again, notice the semicolon: is added to the last line, such as calling a function, in C + +.

The next command is cin.get (). This is another function call: it reads the input and expect the user to
press the button again. Many compiler environments will open a new console window, run the program,
and then close the window. This command makes the window from closing because the program is not
finished because you are waiting for press enter. Including the line that gives you time to see the
running program.

Having achieved the primary end, clamp shut, our program will return the value 0 (and integer, then
why we say the main to return int) for the operating system. The return value is important because it
can used to tell the OS whether our program succeeded or not. A return value of 0 means success and
returned automatically (but only for the main, other functions require you to manually return value), but
if we want to return something else, such as 1, we have to do with return statement:

                #include <iostream>

                using namespace std;

                int main()
                {
                  cout<<" Qrembiezs Intruder was here!n";
                  cin.get();

                    return 1;
                }

Final closing brace of the function. You should try to compile and run this program. You can cut and
paste the code into the file, save it as a cpp file.
An Aside on Commenting Your Programs

When you learn to program, you also have to start learning how to explain your programs (for yourself,
if no one else). You do this by adding a comment to the code, I would use it frequently to help explain
the sample code. When you tell the compiler part of the text comments, he will ignore it when running
the code,allows you to use the text you want to describe the real code. To make a comment make use of
the sign / /, which tells the compiler that the rest of the line is commented out, or / * and then * / to
mark the that all of the comments. Specific compiler environments will change the color of the
comment area, but some do not will. Be certain not accidentally comment out code (that is, to tell the
compiler part of your code is a comments) that you need for this program. When you learn to program,
it is useful to be able to comment section of the code to see how the output is affected.

User interaction and Saving Information with Variables

So far you have learned how to write a simple program to display information typed by you,
programmer, and how to describe your program with the comment. That's fine, but how it interacts
with your users? Fortunately, it is also possible for your program to accept input. You use the function
known as cin, and followed by the insertion operator >>.

Of course, before you attempt to receive input, you must have a place to store input. In programming,
input and the data stored in the variable. There are several types of variable that stores various types of
information (eg numbers Versus letters), you tell the compiler when you declare a variable, you must
include the data type and its name variable. Several basic types include char, int, and float.

A variable of type char stores a single character, variables of type int store integers (numbers without
decimal), and variable of type float store numbers with decimal places. Each type of variable - char, int,
and float - is each keyword that you use when you declare a variable.

What's with all these variable types?

Can sometimes be confusing to have some type of variable when it seems like some kind of
variables are redundant (why when you have an integer number float). Using the right type of variable
may be important to make your code readable and for efficiency - some variables require memory
more than others. In addition, because of the way the numbers are actually stored in memory, the float
is "exact", and should not be used when you have to keep a "proper" value of an integer.
Declaring Variables in C++

To declare a variable that you use the syntax "<name> type:". Here are some examples of variable
declarations:
                   int x;
                   char letter;
                   float the_float;



It is permissible to declare multiple variables of the same type on the same line, each must be separated
by commas.
                   int a, b, c, d;



You may have seen that the variable declarations are followed by a semicolon (note that this is a
procedure that the same used when you call a function).

Common Errors when Declaring Variables in C++

If you try to use a variable that you have stated, your program will not compile or run, and you will
receive an error message informing you that you have made a mistake. Typically, this is called Undeclare
Variable

                   Case Sensitivity

Now is a good time to talk about an important concept that can easily throw you off: sensitivity of the
case. Basically, in C + +, if you use uppercase or lowercase letters p. Cat and kitten word meaning
different for the compiler. In C + +, all language keywords, all functions and all variables are case
sensitive. Differences in variable declarations between you and the use of variables is one reason you
might get error variable

                   Using Variables


Ok, so you now know how to tell the computer about the variables, but how to use them?
Here is a sample program that demonstrates the use of variable

                   #include <iostream>
                   using namespace std;
                   int main()
                   {
                     int thisisanumber;
                     cout<<"Please enter a number: ";
                     cin>> thisisanumber;
                     cin.ignore();
                     cout<<"You entered: "<< thisisanumber <<"n";
                     cin.get();
                   }
Let's take a break and check this program line by line. Int declare thisisanumber keyword to an integer.
Function cin >> to read the value into thisisanumber, the user must press enter before the number is
read by the program. cin.ignore () is a function Another read and discard characters. Remember that
when you type input into the program, it takes the enter as well. We do not need this, so we throw it
away. Note that the variable is declared integer, if the user tries to type a decimal number, it will be
truncated (ie, components of decimal numbers will be ignored). Try typing in sequence of characters or
a decimal number when you run the example program; response will vary from input to input, but
in case it is not too pretty. Note that when printing out a variable quotation marks are not used. Is there
any sign of quotation, the output will be "You Entered:. Thisisanumber" The lack of quotation marks tells
the compiler that there are variables, and because the program should check the value of a variable that
can change the variable names with variables when running the output function. Do not be confused
with the inclusion of two separate insertion operators on one line. Including the operator insertion in
one lines perfectly acceptable and all output will go to the same place. In fact, you must separate string
literals (strings enclosed in quotation marks) and variables by giving each its own insertion operators
(<<). trying to put two variables together with only one << will give an error message, do not try it.
Do not forget to end functions and declarations with a semicolon. If you forget the semicolon, the
compiler will give an error when You try to compile the program.

                Changing and Comparing Variables

Of course, no matter what type you use, the variable is not interesting without the ability to modify
them. Some operator used with variables are as follows: *, -, +, /, =, ==,>, <. * Multiply, which - reduced,
and the + adds. This is of course important to realize that to change the value of the variable in the
program was somewhat important to use the equal sign. In some languages, the equal sign compares
the value of the values of the left and right, but in C + + == used for the task. The equal sign is still very
useful. This sets the left input to the same sign, which should be one, and only one, variable equal to the
value on the right side of the equal sign. Operators that perform mathematical functions should be used
in the right side of the equal sign in order to assign the result to a variable on the left side.
                a = 4 * 6; // (Note use of comments and of semicolon) a is 24
                a = a + 5; // a equals the original value of a with five added to it
                a == 5 // Does NOT assign five to a. Rather, it checks to see if a equals 5.



Other forms of the same, ==, not a way to assign values to variables. Instead, it checks to see whether
the variables are the same. This is useful in other areas of the C + +, for example, you will often use == in
constructs such as conditional statements and loops. You can probably guess how <dan> function. They
are larger than and less than operators.

                a < 5 // Checks to see if a is less than five
                a > 5 // Checks to see if a is greater than five
                a == 5 // Checks to see if a equals five, for good measure



Comparing the variables are not really useful until you have several ways to use it
Tutorial The basics of C++
          Lesson 1
           Special Thanx’s To :
                God Allah
               My Family


      Special Thanx’s to My Team :
             Prabujoyoboyo
                  Loiz
               Xempaxping

               Thanx’s to
                Whitehat
              ./Blacknote
                 Cancer
               Linuxer46
                Shamus
             Cybermuttaqin


      See u in Lesson 2 Basic Of c++
        (I Hope I can write again)

More Related Content

What's hot

Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
Chapter3: fundamental programming
Chapter3: fundamental programmingChapter3: fundamental programming
Chapter3: fundamental programmingNgeam Soly
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.gerrell
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifestohu hans
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping newaprilyyy
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5REHAN IJAZ
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptBinu Paul
 
C language for Semester Exams for Engineers
C language for Semester Exams for Engineers C language for Semester Exams for Engineers
C language for Semester Exams for Engineers Appili Vamsi Krishna
 
Commenting Best Practices
Commenting Best PracticesCommenting Best Practices
Commenting Best Practicesmh_azad
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageRakesh Roshan
 

What's hot (20)

Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
Chapter3: fundamental programming
Chapter3: fundamental programmingChapter3: fundamental programming
Chapter3: fundamental programming
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifesto
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping new
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
Pengaturcaraan asas
Pengaturcaraan asasPengaturcaraan asas
Pengaturcaraan asas
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to Javascript
 
C language for Semester Exams for Engineers
C language for Semester Exams for Engineers C language for Semester Exams for Engineers
C language for Semester Exams for Engineers
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Commenting Best Practices
Commenting Best PracticesCommenting Best Practices
Commenting Best Practices
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
Final requirement
Final requirementFinal requirement
Final requirement
 
C Programming
C ProgrammingC Programming
C Programming
 
C language
C languageC language
C language
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
 
12 Jo P Dec 07
12 Jo P Dec 0712 Jo P Dec 07
12 Jo P Dec 07
 

Viewers also liked

Tutorial basic of c++ lesson 1 ind ver
Tutorial basic of c++ lesson 1 ind verTutorial basic of c++ lesson 1 ind ver
Tutorial basic of c++ lesson 1 ind verQrembiezs Intruder
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programminggajendra singh
 
Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Deepak Singh
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II NotesAndrew Raj
 
Intro. to prog. c++
Intro. to prog. c++Intro. to prog. c++
Intro. to prog. c++KurdGul
 

Viewers also liked (14)

C Tutorials
C TutorialsC Tutorials
C Tutorials
 
C Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.comC Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.com
 
Tutorial basic of c++ lesson 1 ind ver
Tutorial basic of c++ lesson 1 ind verTutorial basic of c++ lesson 1 ind ver
Tutorial basic of c++ lesson 1 ind ver
 
C tutorials
C tutorialsC tutorials
C tutorials
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Ace tutorial c
Ace tutorial cAce tutorial c
Ace tutorial c
 
C vs c++
C vs c++C vs c++
C vs c++
 
C vs c++
C vs c++C vs c++
C vs c++
 
Differences between c and c++
Differences between c and c++Differences between c and c++
Differences between c and c++
 
Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes
 
Intro. to prog. c++
Intro. to prog. c++Intro. to prog. c++
Intro. to prog. c++
 
C tutorial
C tutorialC tutorial
C tutorial
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 

Similar to Tutorial basic of c ++lesson 1 eng ver

Similar to Tutorial basic of c ++lesson 1 eng ver (20)

C++ for hackers
C++ for hackersC++ for hackers
C++ for hackers
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
C++ How to program
C++ How to programC++ How to program
C++ How to program
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
Cp week _2.
Cp week _2.Cp week _2.
Cp week _2.
 
lecture1 pf.pptx
lecture1 pf.pptxlecture1 pf.pptx
lecture1 pf.pptx
 
C plus plus for hackers it security
C plus plus for hackers it securityC plus plus for hackers it security
C plus plus for hackers it security
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
 
Basic c
Basic cBasic c
Basic c
 
C-PROGRAM
C-PROGRAMC-PROGRAM
C-PROGRAM
 
C programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdfC programming language tutorial for beginers.pdf
C programming language tutorial for beginers.pdf
 
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxIIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
 
67404923-C-Programming-Tutorials-Doc.pdf
67404923-C-Programming-Tutorials-Doc.pdf67404923-C-Programming-Tutorials-Doc.pdf
67404923-C-Programming-Tutorials-Doc.pdf
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Programming in C++
Programming in C++Programming in C++
Programming in C++
 
The C++ Programming Language
The C++ Programming LanguageThe C++ Programming Language
The C++ Programming Language
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 

Recently uploaded

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 

Recently uploaded (20)

LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 

Tutorial basic of c ++lesson 1 eng ver

  • 1.
  • 2. Getting Set Up - C++ Compilers The first thing you need to do, before starting on the C + +, is to ensure that you have a compiler. What compiler, you ask? A compiler converts a program you write to an executable that your computer iscan correctly understand and execute. If you take the course, you may have one administered through your school. If you start out on your own, your best bet is to use Code :: Blocks with MinGW. If you are on Linux,You can use g + +, and if you are on Mac OS X, you can use Xcode Intro to the C++ Language A C + + program is a collection of commands that tell the computer to do "something". Collection of orders is usually called C + + source code, source code or just the code. A good command "function" or "keyword". Keyword is a block basic building blocks of language, while the function is, in fact, usually written in the form of simple functions - you'll see this in our first program, below. ? (Confused Think of it less as a framework for a books; line may indicate each chapter in this book, each chapter may have its own line, made up of sections each section may have its own line, or it may have all. written details) Happily., C + + provides the functionality of the general and the keywords you can use. But how does a program actually begin? Each program in C + + has a function, is always named main, which is always called when your program first starts up. Of the primary, you can also call the function- other functions if they were written by us or, as mentioned earlier, provided by the compiler. So how do you get access to prewritten functions? To access the functions that come standard with compiler, you include a header with the directive # include. What this does is effectively take everything in the header and paste it into your program. Let's look at the work program: #include <iostream> using namespace std; int main() { cout<<"Qrembiezs Intruder was here!n"; cin.get(); } Let's take a look at the elements of the program. The # include is a "preprocessor" directive that tells the compiler to put the code in the header called iostream into our program before actually making the executable. by including header file, you get access to different functions. For example, the function requires iostream court. Follow include the statement, "using namespace std; '. This line tells the compiler to use the group functions is part of the standard library (std). By including this line at the top of the file, you allow the program to using functions like a court. The semicolon is part of the syntax of C + +. This tells the compiler that you at the end of the command. You will see later that the semicolon is used to end most commands in C + +.
  • 3. The next important line is int main (). This line tells the compiler that a function called main, and that function returns an integer, hence int. The "curly braces" ({and}) signal the beginning and end of the function and other code blocks. You can think of them as the meaning of BEGIN and END. The next line of the program may seem strange. If you have programmed in other languages, you may wish to print will be a function used to display text. In C + +, however, the courts are used for object display text (pronounced "C out"). It uses the << symbols, known as "insertion operator", to show what is the output. cout << result in the function call with the following text as an argument to the function. citing informed compiler that you want to output a string literal is. The sequence ' n' is actually treated as a single character stands for a new line (we'll discuss this in more detail later). This moves the cursor on your screen to the line next. Again, notice the semicolon: is added to the last line, such as calling a function, in C + +. The next command is cin.get (). This is another function call: it reads the input and expect the user to press the button again. Many compiler environments will open a new console window, run the program, and then close the window. This command makes the window from closing because the program is not finished because you are waiting for press enter. Including the line that gives you time to see the running program. Having achieved the primary end, clamp shut, our program will return the value 0 (and integer, then why we say the main to return int) for the operating system. The return value is important because it can used to tell the OS whether our program succeeded or not. A return value of 0 means success and returned automatically (but only for the main, other functions require you to manually return value), but if we want to return something else, such as 1, we have to do with return statement: #include <iostream> using namespace std; int main() { cout<<" Qrembiezs Intruder was here!n"; cin.get(); return 1; } Final closing brace of the function. You should try to compile and run this program. You can cut and paste the code into the file, save it as a cpp file.
  • 4. An Aside on Commenting Your Programs When you learn to program, you also have to start learning how to explain your programs (for yourself, if no one else). You do this by adding a comment to the code, I would use it frequently to help explain the sample code. When you tell the compiler part of the text comments, he will ignore it when running the code,allows you to use the text you want to describe the real code. To make a comment make use of the sign / /, which tells the compiler that the rest of the line is commented out, or / * and then * / to mark the that all of the comments. Specific compiler environments will change the color of the comment area, but some do not will. Be certain not accidentally comment out code (that is, to tell the compiler part of your code is a comments) that you need for this program. When you learn to program, it is useful to be able to comment section of the code to see how the output is affected. User interaction and Saving Information with Variables So far you have learned how to write a simple program to display information typed by you, programmer, and how to describe your program with the comment. That's fine, but how it interacts with your users? Fortunately, it is also possible for your program to accept input. You use the function known as cin, and followed by the insertion operator >>. Of course, before you attempt to receive input, you must have a place to store input. In programming, input and the data stored in the variable. There are several types of variable that stores various types of information (eg numbers Versus letters), you tell the compiler when you declare a variable, you must include the data type and its name variable. Several basic types include char, int, and float. A variable of type char stores a single character, variables of type int store integers (numbers without decimal), and variable of type float store numbers with decimal places. Each type of variable - char, int, and float - is each keyword that you use when you declare a variable. What's with all these variable types? Can sometimes be confusing to have some type of variable when it seems like some kind of variables are redundant (why when you have an integer number float). Using the right type of variable may be important to make your code readable and for efficiency - some variables require memory more than others. In addition, because of the way the numbers are actually stored in memory, the float is "exact", and should not be used when you have to keep a "proper" value of an integer.
  • 5. Declaring Variables in C++ To declare a variable that you use the syntax "<name> type:". Here are some examples of variable declarations: int x; char letter; float the_float; It is permissible to declare multiple variables of the same type on the same line, each must be separated by commas. int a, b, c, d; You may have seen that the variable declarations are followed by a semicolon (note that this is a procedure that the same used when you call a function). Common Errors when Declaring Variables in C++ If you try to use a variable that you have stated, your program will not compile or run, and you will receive an error message informing you that you have made a mistake. Typically, this is called Undeclare Variable Case Sensitivity Now is a good time to talk about an important concept that can easily throw you off: sensitivity of the case. Basically, in C + +, if you use uppercase or lowercase letters p. Cat and kitten word meaning different for the compiler. In C + +, all language keywords, all functions and all variables are case sensitive. Differences in variable declarations between you and the use of variables is one reason you might get error variable Using Variables Ok, so you now know how to tell the computer about the variables, but how to use them? Here is a sample program that demonstrates the use of variable #include <iostream> using namespace std; int main() { int thisisanumber; cout<<"Please enter a number: "; cin>> thisisanumber; cin.ignore(); cout<<"You entered: "<< thisisanumber <<"n"; cin.get(); }
  • 6. Let's take a break and check this program line by line. Int declare thisisanumber keyword to an integer. Function cin >> to read the value into thisisanumber, the user must press enter before the number is read by the program. cin.ignore () is a function Another read and discard characters. Remember that when you type input into the program, it takes the enter as well. We do not need this, so we throw it away. Note that the variable is declared integer, if the user tries to type a decimal number, it will be truncated (ie, components of decimal numbers will be ignored). Try typing in sequence of characters or a decimal number when you run the example program; response will vary from input to input, but in case it is not too pretty. Note that when printing out a variable quotation marks are not used. Is there any sign of quotation, the output will be "You Entered:. Thisisanumber" The lack of quotation marks tells the compiler that there are variables, and because the program should check the value of a variable that can change the variable names with variables when running the output function. Do not be confused with the inclusion of two separate insertion operators on one line. Including the operator insertion in one lines perfectly acceptable and all output will go to the same place. In fact, you must separate string literals (strings enclosed in quotation marks) and variables by giving each its own insertion operators (<<). trying to put two variables together with only one << will give an error message, do not try it. Do not forget to end functions and declarations with a semicolon. If you forget the semicolon, the compiler will give an error when You try to compile the program. Changing and Comparing Variables Of course, no matter what type you use, the variable is not interesting without the ability to modify them. Some operator used with variables are as follows: *, -, +, /, =, ==,>, <. * Multiply, which - reduced, and the + adds. This is of course important to realize that to change the value of the variable in the program was somewhat important to use the equal sign. In some languages, the equal sign compares the value of the values of the left and right, but in C + + == used for the task. The equal sign is still very useful. This sets the left input to the same sign, which should be one, and only one, variable equal to the value on the right side of the equal sign. Operators that perform mathematical functions should be used in the right side of the equal sign in order to assign the result to a variable on the left side. a = 4 * 6; // (Note use of comments and of semicolon) a is 24 a = a + 5; // a equals the original value of a with five added to it a == 5 // Does NOT assign five to a. Rather, it checks to see if a equals 5. Other forms of the same, ==, not a way to assign values to variables. Instead, it checks to see whether the variables are the same. This is useful in other areas of the C + +, for example, you will often use == in constructs such as conditional statements and loops. You can probably guess how <dan> function. They are larger than and less than operators. a < 5 // Checks to see if a is less than five a > 5 // Checks to see if a is greater than five a == 5 // Checks to see if a equals five, for good measure Comparing the variables are not really useful until you have several ways to use it
  • 7. Tutorial The basics of C++ Lesson 1 Special Thanx’s To : God Allah My Family Special Thanx’s to My Team : Prabujoyoboyo Loiz Xempaxping Thanx’s to Whitehat ./Blacknote Cancer Linuxer46 Shamus Cybermuttaqin See u in Lesson 2 Basic Of c++ (I Hope I can write again)