Professional Documents
Culture Documents
Assignment C Programming
Assignment C Programming
PROGRAMMIN
G LAB. REPORT
DEPARMENT
: DEM1B
NAME
SHAHRIL ANWAR
: MOHAMAD
: 01DEM15F1084
: 24 JULAI 2015
INTRODUCTION
In mathematics and computer science,
an algorithm is a self-contained step-bystep set of operations to be performed.
Algorithms exist that perform
calculation, data processing, and
automated reasoning.
An algorithm is an effective method that
can be expressed within a finite amount
of space and time and in a well-defined
formal language for calculating a
function. Starting from an initial state
and initial input (perhaps empty), the
instructions describe a computation
that, when executed, proceeds through
a finite number of well-defined
successive states, eventually producing
"output" and terminating at a final
ending state. The transition from one
state to the next is not necessarily
deterministic; some algorithms, known
as randomized algorithms, incorporate
random input.
EXERCISE 2
EXERCISE 3
EXERCISE 1
ALGORITHM
1)
bulatan =
bulatan = 22/7 * r * r
Variable = bulatan, r,
1)
2)
3)
4)
5)
6)
7)
Start
Declare bulatan, r,
Input r,
Storage r,
Process bulatan = 22/7 * r* r,
Display bulatan
End
2)
1)
2)
3)
4)
5)
6)
7)
3)
1)
2)
3)
4)
5)
6)
Square = L* P
Start
Declare Square, L, P,
Input L, P,
Storage L, P,
Process Square = L* P,
Display Square
End
Triangle = 1/2 * b * h
Start
Declare Triangle, b, h,
Input b, h,
Storage b, h,
Process Triangle = b* h,
Display Triangle
7)
End
Start
Declare
1/2, b, h
Input
b, h,
Storage
b, h,
Process
Triangle = 1/2 * b * h
Display
Triangle
End
CONCLUSION
Untuk mengelakkan ralat,kita perlu mengikut format Cprogramming iaitu:
int : No.Bulat
No.Perpuluhan
#include <stdio.h>
#include <stdio.h>
main()
main()
int a,b,X;
float A,r;
scanf(%d,&a);
scanf(%f,&r);
A=3.142*r*r;
scanf(%d,&b);
printf(Display value A=
%f,A);
X=a+b
printf(Display value X=
%d,X);
return 0;
}
float
return 0;
}
DISCUSSION
4.