You are on page 1of 14

Assoc. Prof.

Mohamed Moawad Abdelsalam


Head of Computers Engineering and Control Systems dep., Director of Biomedical
Engineering Program, Faculty of Engineering, Mansoura University

E-mail: mohmoawad@mans.edu.eg

Lecture 1
How to Set Up a Development Environment for
C Programming
To start writing C programs on your local machine, you will need the
following:
• A C Compiler
• An Integrated Development Environment (IDE)
Steps of C Programming
Types of programming errors
These errors are mainly
occurred due to the mistakes
while typing

When the program is


running, and it is not able to
perform the operation

when the executable file of the


program is not created

These errors produce the


incorrect output

Occurred when the


statements are not
understandable by the
compiler 4
Flow Chart Symbols
Example: Client Brief “Panic Alarm”
“Medicare Ltd are developing a new call system for patients. Their hardware has a
nurse station and a single room. Medicare Ltd are looking for a program design that
will provide the right signals to healthcare professionals on the ward. A summons
button is placed next to the bedside of the patient and allows a patient to summon a
medical professional. If the button is pressed and released, it is classed as a normal
priority signal. However, if the button is held for more than 2 seconds it is considered
a high priority signal.
• When a normal priority signal occurs, speakers at the monitoring station and in the
patients’ room should emit a doorbell (ding-dong) sound and a light above the
patients’ room doorway will turn amber.
• For high priority signals, a klaxon sound should be emitted from speakers. The light
above the doorway should turn red.
• When the healthcare professional answers the summons by entering the patients’
room, they press a separate button to turn off the light outside the room and all
emitted sounds must end.”
Writing a C-program
#include<stdio.h> Header File

void main()
{
Variable declarations;
// This is the program body comment

The program body;


}
Header File
• Header files contain a set of predefined standard library functions
• The .h is the extension of the header files in C .
• Header files contain functions.
• It can be declared as:

#include < ****.h>


Data types and Variable Declarations

int a;
short int a,b=11,d=-240;
long int c=296863,f;

Float p,q=2.795;
double n,q=3695.3698526;

char name, letter=‘X’;


Standard Input – Output Functions
1. Input function : Receive the inputs from the keyboard
Scanf (“ %Data_type”, & variable);
Integer %d
Float %f
Character %c
Example: read an integer number and store in a variable called “num”
scanf(“%d”, &num);
Example: read two float numbers and store them in “num1” and “num2”
scanf(“%f %f”, &num1, &num2);
Example: read three characters and store them in “let1” , “let2” and “let3”
scanf(“%c %c %c”, &let1, &let2, &let3);
2. Output function : print the outputs on the screen
printf (“ %Data_type”, variable);
Example: print a amessage “Hello world”
printf(“Hello World”);
Example: print an integer number that stored a variable called “num”
printf(“%d”, num);
Example: print two float numbers that stored in “num1” and “num2”
printf(“number1=%f and number2= %f”, num1, num2);
Example 1: Write a program to print “Hello world” message on the
screen.

#include<stdio.h>
void main()
{
printf(“Hello World”);
}
Example 1: Write a program to read two integer numbers and print
their summation and average.

#include<stdio.h>
void main()
{
int num1,num2,sum;
float aver;
scanf(“%d %d”, &num1,&num2);
sum=num1+num2;
aver=(num1+num2)/2;
printf(“The summation =%d, and the average=%f”,sum,aver);
}

You might also like