Cs 103 Computer System and Programming: Chapter 02: C++ Programming Basics
Cs 103 Computer System and Programming: Chapter 02: C++ Programming Basics
Cs 103 Computer System and Programming: Chapter 02: C++ Programming Basics
AND PROGRAMMING
CHAPTER 02: C++ PROGRAMMING BASICS
D E PA R T M E N T O F C I V I L E N G I N E E R I N G , FA C U LT Y O F
E N G I N E E R I N G A N D T E C H N O L O G Y,
I N T E R N AT I O N A L I S L A M I C U N I V E R S I T Y H - 1 0 , I S L A M A B A D ,
PA K I S TA N
H T T P : / / W W W. I I U . E D U . P K
CS 103 COMPUTER SYSTEM AND
PROGRAMMING
Course Code CS103
Course Title Computer System & Programming
Credit Hours 1+2
Contact Hr 1+6
Pre-Requisite None
Text Books Introduction to Matlab for Engineers.
Reference Books Object Oriented Programming by Robert Lafore
Let Us C++ by Yashwant Kanetkar
Objective of Course Objective of Course
To develop skills of computer programming and its applications in
elementary civil engineering problems
Course Outline Programming for Civil Engineers:
Objective of this course is to learn basics of
programming and its application to Civil
Engineering. Programming Language can be C++,
SCILAB Scripting, MATLAB Scripting or VB.NET.
Variables, Constant, Control Structures, Loop,
Functions, Sub Procedure, Plotting, Matrix
Operation, Solving System of linear Equations,
Arithmetic Calculator, Solving Simple Numerical
Problem of Engineering and Mathematical
Subjects, Solving Calculus, Differential and Integral
CS 103 COMPUTER SYSTEM AND PROGRAMMING
Marks Distribution of
CSP (Theory)
Quizes 10%
Assignments 05%
Sessional 1 20%
Sessional 2 15%
Marks Distribution of
CSP Lab
Lab Tasks 15 %
Explanation:
This program consists of a single function
called main().
BASIC PROGRAM CONSTRUCTION
Because of the parentheses() the compiler
comes to know that this a function not a
variable.
The parentheses aren’t always empty. They’re
used to hold function arguments (values passed
from the calling program to the function).
Line number 2 and 3 are not part of the
function.
The word int preceding the function name
indicates that this particular function has a
return value of type int.
The body of a function is surrounded by braces
(sometimes called curly brackets).
BASIC PROGRAM CONSTRUCTION
Every function must use this pair of braces
around the function body.
A function body can consist of many statements
but this function has only three statements
(line number 5, 6 and 7)
You can put several statements on one line and
one statement in over two or more lines.
1 cout
2 <<“Welcome to this course\n”
3 ;
#include <iostream>
using namespace std;
int main(){
int count = 10;
cout << "count=" << count << endl; // displays 10