Introduction To Scientific and Engineering Computation (BIL 110E)
Introduction To Scientific and Engineering Computation (BIL 110E)
and Engineering
Computation
(BIL 110E)
Lecture 1
Introduction to C programming
Introduction
• As engineers and scientists why do we need computers?
A computer is a device that can perform computations and makes logical
decisions billions of times faster than human beings can.
• Why do we need computer program ?
A computer is a machine that performs operations that are specified with a
set of instructions called a program.
• What is C ?
C is a high level programming language. The C language was first
developed in 1972 by Dennis Ritchie at AT&T Bell Labs.
• Why C ?
C is one of the most popular general purpose programming language.
1
Computer Languages
High-level Languages
Advantages of high-level languages including C:
2
C Development Environment
3
Example
Problem statement:
– Should be clear and avoid any misunderstanding.
Example
Input/Output Description :
– Information that is given and the values to be computed.
Point 1
Distance between two
points
Point 2
4
Example
Hand Example :
p1 (1,5)
p2 (4,7) (4,7)
side2
2 2
dist ( side1 ) ( side2 ) (dis)
(4 1) 2 (7 5) 2 (1,5)
side1
13
3.61
Example
Algorithm Development :
– Algorithm is a step-by-step outline of the problem
solution, in other words simple operations performed one
after another.
10
5
Example 1
/*--This program computes the distance between two points-----*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
main()
{
/*----- Declare and initialize variables----- */
double x1=1, y1=5, x2=4, y2=7;
double side1, side2, dist ;
11
Example 2
#include <stdio.h>
int main () {
int ch;
return(0);
}
12
6
Example
Testing :
– Data from the hand example can be used for testing.
13