100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

COS1511 Book Summary

Rating
4.3
(3)
Sold
21
Pages
41
Uploaded on
23-07-2019
Written in
2018/2019

This document consists of a summary of the whole module for revision

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
July 23, 2019
Number of pages
41
Written in
2018/2019
Type
Summary

Subjects

Content preview

Lesson 1 - Your first program
Friday, 03 March 2017 11:53 AM

General rule:
Always use << with cout.


Include <iostream>:
Special instruction that we always put at the top of the code to tell the compiler to include the
iostream header file. Header files basically define a number of additional instructions that we can
use in our programs to make them simpler and neater. A particularly useful one is iostream. The io in
iostream stands for Input/Output and this header file allows us to use the cout instruction to output
messages to the screen.


namespace std;
Some C++ compilers allow you to leave this out.


#include <iostream>
int main( )
{
std::cout << "Hello world";
return 0;
}


cout is defined in the iostream header file. All the names defined in it belong to a namespace called
std. If you don't use using namespace std; in your program, then you should prefix every name that
belongs to the std namespace with std::.


int main( )
This is the header for the main function of the program.


Semicolons:
Semicolon is called a statement terminator. Each statement must be terminated by a semicolon.


cout <<:
Stands for console output (display). Pronounce cout as “see-out”


Comment statement:
Is a text that we add to a program that has no effect on the running of the program but that is
generally used to explain what the programming (or part of the program) does.


//This is a comment statement



UNISA Page 1

, Endl:
Endl stands for end line. When used with cout it makes output continue on the next line.


C++ Structure:
//DescriptiveComment
#include <StandardHeaderFile>
using namespace std;

int main( )
{
StatementSequence;
}





UNISA Page 2
$4.85
Get access to the full document:
Purchased by 21 students

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Reviews from verified buyers

Showing all 3 reviews
5 year ago

5 year ago

5 year ago

4.3

3 reviews

5
2
4
0
3
1
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Naz1611 University of South Africa (Unisa)
Follow You need to be logged in order to follow users or courses
Sold
87
Member since
6 year
Number of followers
81
Documents
0
Last sold
3 year ago

4.0

7 reviews

5
3
4
1
3
3
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions