Professional Documents
Culture Documents
Lect # 2
Lect # 2
Lect # 2
FUNDAMENTALS
Instructor: Ms. Madiha Rehman
Objectives
Description
Main() must return int. The return value is passed back to the operating System to indicate whether the
program ran successfully.
We can leave the int from main, in that case it will always return zero
using namespace std;
std is the standard namespace, cout, cin and a lot of other things are defined in it.
To omit writing std:: , we need to include the std namespace, i.e.,
#include <iostream>
using namespace std;
int main() { cout<<“Hello World”; }
This means that one way to call them is by using std::cout and std::cin. And another way is to add the
namespace.
The keyword using technically means, use this whenever you can. This refers, in this case, to the std
namespace.
Class Activities
Class Activity 1: Write a C++ Program to display the following output:
Hello World
C++ Programming is fun
Class Activity 2: Create and execute a program that outputs your name on one line and your age on
the next line.
Class Activity 3: The following program produces several compiler errors. Find these errors and
correct them so the program can compile cleanly and run.
include <iostream>
Int main()
{
std:cout << "Hello World" << std:endl
)