0% found this document useful (0 votes)
12 views6 pages

PW1

This document outlines a practical work session on programming fundamentals in C language. It includes 4 practical assignments on installing Dev-Cpp, writing a simple "Hello World" program, fixing errors in an example program, and modifying that program. Students are assessed on their ability to complete tasks, manipulate programs, build programs, and participate in labs. The assignments introduce students to the C programming environment, writing, compiling and executing code, and modifying existing programs.

Uploaded by

Miza Khairina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

PW1

This document outlines a practical work session on programming fundamentals in C language. It includes 4 practical assignments on installing Dev-Cpp, writing a simple "Hello World" program, fixing errors in an example program, and modifying that program. Students are assessed on their ability to complete tasks, manipulate programs, build programs, and participate in labs. The assignments introduce students to the C programming environment, writing, compiling and executing code, and modifying existing programs.

Uploaded by

Miza Khairina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

ELECTRICAL ENGINEERING DEPARTMENT

ACADEMIC SESSION: _2 2021/2022

DEC20012: PROGRAMMING FUNDAMENTALS

build programs written in C language for assigned mini project during practical
CLO2
work session ( P4 , PLO 5 )
PRACTICAL WORK 1 : Introductory to C Programming
PRACTICAL WORK DATE :

LECTURER’S NAME:

NAME :
TOTAL MARKS
STUDENT ID :
Fixes /5
Complete /5
Manipulates /5
Builds /5
Practical Skill Display /5
Assessment
Lab Participation /5
[CLO2]
Efficiency /5
Theory /5
Total /40
A. Total Practical Skill Assessment 80% /80
Report Discussion /15
Assessment Conclusion /5
B. Total Report Assessment /20
Total A+B (100%) /100

SUBMISSION DATE : RETURN DATE :


1 LEARNING OUTCOMES (LO):
1. Install Dev-Cpp Installer form CIODS lms and familiarize with the environment.
2. Write, compile and execute C program using a formal C editor and compiler.
3. Manipulate given simple C program example.
2 OBJECTIVES:
1. To introduce student with the C editor and compiler environment.
2. To write, compile and execute a simple C program example.
3. To modify a given C program, compile and execute to produce different output.
3 THEORY

C Program

The scanf() function


The function scanf in stdio.h is to read inputs entered from the keyboard. It has the following form
scanf(“%f”,&a);

The printf() function

In general, printf () is a library function under C header file stdio.h and conio.h both. And generally, it is


used for displaying an outcome of a program to outside world. Printf() function is often used to our
program to do formatted output. All variants of printf function use same formatting techniques. There is
a string that specifies the layout of output is call format specifier. i.e. %s, %d, %f, %c, %x, %u and
others.

printf(“The value of the current is %f amps”,current);

Sample of C Program Compile and Execute

Variables and Constant


 In programming, a variable is defined as a computer memory that can store data temporarily,
where the value can always be changed.
 In programming, a constant is defined as a computer memory that can store data temporarily,
where the value is fix and cannot be changed during execution.

Declaring variables and constant

To declare a variable, you must declare its type and identifier. To declare a constant, keyword const
and #define are used in a program.

int my_Numb3r;

const phi = 3.142; OR #define phi 3.142;


Operators and Expressions

What happens after the data is stored in variables?


Naturally, a computer will process the data. The process include conducting arithmetic, relational,
logical and other operations needed to carry out the desired output.

What is operator?
An operator is a symbol which operates on a value or a variable. For example: + is an operator to
perform addition.

Operators used in C:
Arithmetic Operators +, -, *, /, %
Unary Operators ++, - -
Assignment Operators =, +=, - =, *=
Relational Operators <, >, <=, >=, = =, !=
Logical Operators &&, ||, !
4 EQUIPMENT / TOOLS
Computer, C programming language (Dev-cpp, codeblock, etc.)

Practical Assignments 1: Dev-Cpp installation and environment


Download Dev-Cpp from CIDOS lms for DEC20012 platform or other sources available.
1. Open the folder and execute Setup.exe application program to install the software on your PC/Laptop.
2. Respond Yes to the first dialogue box, select English for the language and click OK.
3. Click I Agree button and click Next.
4. Click Install or browse for other folder if you wish to save the software other than default folder.
5. Wait for the installation progress and click Finish.
6. In the Dev-C++ First time Configuration dialogue box, click Next 2 times and click OK and then
Configuration is Successful and you are in the Dev-C++ development environment.
Open the Dev-C++ software (for the second or following times you open the software)
1. Choose File and select New Project
2. Select Console Application and Click OK

3. Give the file you want to work with a name and browse the folder where you wish to save the files.
and click Save.

4. You are now in Dev-C++ development environment:

5. You can start editing a new program now.


Practical Assignments 2: My First C Program
 Type the following program in the Dev-C++ Editor

#include<stdio.h>  compile the


int main() program when
{ finished
printf("\nWELCOME TO PROGRAMMING CLASS!!"); typing.
return 0;  Run the
}
program

Output: Screenshot your output and print


Practical Assignments 3: Fix A C Program
Complete Program: (Fill all the blanks with correct commands)

…………………<stdio.h>

int main()

…………

char name[20];
int staff_no;

printf(“Enter your name:\n”);


scanf(“%s”, ………………….);
printf(“Enter your Staff No:”);
scanf(“%d”,&staff_no);
printf(“Mr/Ms ……………, your Staff No is %d”,name,………………….”);
return 0;
}

Paste the completed program:

Output: Screenshot your output and print

Practical Assignments 4: Modify Practical Assignment 3 Program


Based on Practical Assignment 3, modify the code to get the following output:

Output:

Enter ID : ……………………
Enter Password : ……………………..

Please confirm that your ID is ……………………….. and password …………………….. .


Thank you.

Paste the completed program:


Output: Screenshot your output and print

Discussion for Practical 1:

1) Discuss what is the data input and output. (5 Marks)

2) Define constant and variables. (4 Marks)

3) State the data types used in C programming. (6 Marks)

Conclusion for Practical 1:

You might also like