20180728111553D5542 - COMP6047 (L) Pert 1 - Algorithm & Programming and Introduction To C Programming
20180728111553D5542 - COMP6047 (L) Pert 1 - Algorithm & Programming and Introduction To C Programming
• Additional Textbook
Jeri R. Hanly , Elliot B. Koffman. 2009. Problem Solving and
Program Design in C. ADWES. Boston, Massachusetts, USA.
ISBN:978-0321535429
Syntax Err
Executable code:
=> Run
Output Err
Input a,b,c
d = b^2 – 4ac
d<0 Y
T
x1=(-b+sqrt(d))/2a Print message
x2 =(-b-sqrt(d))/2a “Imaginary”
Print: x1, x2
Stop
• Portability
Used from micro computer to super computer
}
// This program will simply print out a message
• ASCII
American Standard Code for Information Interchange
http://www.asciitable.com/
or:
int x, y, z;
or:
• Void data type: is data type that can be transform into any data
type (will be discussed later in pointer)
• Example :
sizeof(int) = 4 => Dev-V (Windows)
sizeof(int) = 2 => Turbo C ver 2.0 (DOS)
• Example :
– 3.14 (double)
– 3.14f (float)
– 3.14L (long double)
• Example :
– 174 (integer)
– 174u (unsigned integer)
– 174L (long integer)
– 174ul (unsigned long integer)
• How to deal with the issue? You may use casting or suffix
float x;
x = (float)3.14; // casting
x = 3.14f; // or suffix