LAB # 01
Statement Purpose:
This lab will give you an overview of C++ language.
Activity Outcomes:
This lab teaches you the following topics:
Basic syntax of C++
Data types and operators in C++
Control flow statements in C++
Arrays and Functions
Instructor Note:
Introduction to Programming in C++
https://ece.uwaterloo.ca/~dwharder/aads/Tutorial/
http://www.cplusplus.com
3
, 1) Stage J (Journey)
Introduction
C++, as we all know is an extension to C language and was developed by Bjarne
stroustrup at bell labs. C++ is an intermediate level language, as it comprises a
confirmation of both high level and low level language features.
Following features of C++ makes it a stronger language than C,
1. There is Stronger Type Checking in C++.
2. C++ supports and allows user defined operators (i.e Operator Overloading) and
function overloading is also supported in it.
3. Exception Handling is there in C++.
4. Inline Functions in C++ instead of Macros in C language. Inline functions make
complete function body act like Macro, safely.
5. Variables can be declared anywhere in the program in C++, but must be declared
before they are used.
2) Stage a1 (apply)
Lab Activities:
Activity 1:
Write a Hello World program in C++.
Solution:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World! ";
cout << "I'm a C++ program";
}
Activity 2:
Write a program to use different data types in C++
Solution:
4
Statement Purpose:
This lab will give you an overview of C++ language.
Activity Outcomes:
This lab teaches you the following topics:
Basic syntax of C++
Data types and operators in C++
Control flow statements in C++
Arrays and Functions
Instructor Note:
Introduction to Programming in C++
https://ece.uwaterloo.ca/~dwharder/aads/Tutorial/
http://www.cplusplus.com
3
, 1) Stage J (Journey)
Introduction
C++, as we all know is an extension to C language and was developed by Bjarne
stroustrup at bell labs. C++ is an intermediate level language, as it comprises a
confirmation of both high level and low level language features.
Following features of C++ makes it a stronger language than C,
1. There is Stronger Type Checking in C++.
2. C++ supports and allows user defined operators (i.e Operator Overloading) and
function overloading is also supported in it.
3. Exception Handling is there in C++.
4. Inline Functions in C++ instead of Macros in C language. Inline functions make
complete function body act like Macro, safely.
5. Variables can be declared anywhere in the program in C++, but must be declared
before they are used.
2) Stage a1 (apply)
Lab Activities:
Activity 1:
Write a Hello World program in C++.
Solution:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World! ";
cout << "I'm a C++ program";
}
Activity 2:
Write a program to use different data types in C++
Solution:
4