You are on page 1of 12

PROGRAMMING FUNDAMENTAL

LECTURE 3

1
FLOW CHART
BASIC SYMBOLS
EXAMPLE

ADD TWO NUMBER AND


DISPLAY THE SUM.
FIND THE GREATEST OF
THREE NUMBERS.
PRACTICE

• Draw flow chat to make tea.


• Draw flow chart to subtract three number.
• Draw flow chart to find whether the entered
number is multiple of 5.
• Draw flow chart to find whether entered number is
prime or not.
HISTORY OF C++
C, C++, Java, and C# are very similar. C++ evolved from C. Java
was modeled after C++. C# is a subset of C++ with some features
similar to Java. If you know one of these languages, it is easy to learn
the others.
C evolved from the B language and the B language evolved from the
BCPL language.
BCPL was developed by Martin Richards in the mid-1960s for
writing operating systems and compilers.
C++ is an extension of C, developed by Bjarne Stroustrup at Bell
Labs during 1983-1985.
C++ added a number of features that improved the C language.
Most importantly, it added the An international standard for C++ was
created by American National Standards Institute (ANSI) in 1998.
7
A SIMPLE C++ PROGRAM
Let us begin with a simple C++ program that displays the message
“Welcome to C++!” on the console.
#include <iostream>
using namespace std;
int main()
{
// Display Hello World! to the console
cout << “Hello World!”;
return 0;
}

8
EXTENDING THE SIMPLE C++ PROGRAM

Once you understand the program, it is easy to extend it to display


more messages. For example, you can rewrite the program to display
three messages, as shown in Listing 1.2.
#include <iostream>
using namespace std;
int main()
{
cout << "Programming is fun!" << endl;
cout << "Fundamentals First" << endl;
cout << "Problem Driven" << endl;
return 0;
}

9
CREATING,
COMPILING,
Source code (developed by the programmer)
Create/Modify Source Code
#include <iostream>

AND RUNNING
using namespace std;

int main() Saved on the disk


{

PROGRAMS
// Display Welcome to C++ to the console
cout << "Welcome to C++!" << endl; Source Code
return 0;
}

Compiler
If compilation errors
stored on the disk

An object file (e.g., Welcome.obj) is created.


Machine Code
program

Linker

stored on the disk

An executable file (e.g., Welcome.exe) is created.


Executable Code

Run Executable Code


e.g., Welcome

Result

If runtime errors or incorrect result

10
PRACTICE

What is a comment? What is the syntax for a comment in C++? Is


the comment ignored by the compiler?
What is the statement to display a string on the console?
What does the namespace std stand for?
Which of the following preprocessor directive is correct?
a. import iostream
b. #include <iostream>
c. include <iostream>
d. #include iostream
PRATICE

Which of the following preprocessor directive will work with all C++ compilers?
a. #include < iostream>
b. #include <iostream >
c. include <iostream>
d. #include <iostream>
Can C++ run on any machine? What is needed to compile and run C++ programs?
What are the input and output of a C++ compiler?

You might also like