0% found this document useful (0 votes)
114 views14 pages

Practical Work 6

This document contains details of a programming fundamentals practical work session on arrays for electrical engineering students. It includes 5 practical assignments for students to complete involving declaring, initializing, manipulating and displaying array elements in C programs. It also requires students to submit a report discussing and concluding their understanding of the practical work on arrays. Lecturers will assess students' practical skills in completing the assignments and the quality of their written reports.

Uploaded by

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

Practical Work 6

This document contains details of a programming fundamentals practical work session on arrays for electrical engineering students. It includes 5 practical assignments for students to complete involving declaring, initializing, manipulating and displaying array elements in C programs. It also requires students to submit a report discussing and concluding their understanding of the practical work on arrays. Lecturers will assess students' practical skills in completing the assignments and the quality of their written reports.

Uploaded by

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

ELECTRICAL ENGINEERING DEPARTMENT

ACADEMIC SESSION: _____________


DEC20012: PROGRAMMING FUNDAMENTAL
build programs written in C language for assigned mini project during
CLO2
practical work session ( P4 , PLO 5 )
PRACTICAL WORK 6 : Array
PRACTICAL WORK DATE :
LECTURER’S NAME:

NAME : TOTAL
STUDENT ID : MARKS
Fixes
Complete
Manipulates
Practical Skill Builds
Assessment Display
[CLO2] Lab Participation
Efficiency
Total Practical Skill Assessment
Total Practical Skill Assessment (80%) = /35 *80
Theory
Report Discussion
Assessment Conclusion
Total Report Assessment
Total Report Assessment (20%) = /15*20
Total A+B (100%)
DATE SUBMIT : DATE RETURN :
1 LEARNING OUTCOMES (LO):
1. Understand ARRAY statements.
2. Apply ARRAY statements.
2 OBJECTIVE
1. Define ARRAY statement..
2. Identify the need for ARRAY in programming.
3. Describe the structure of ARRAY..
4. Accessing Array Elements
3 THEORY
Declaring an ARRAY
4 EQUIPMENT / TOOLS
Computer, C programming language ( Dev-cpp, codeblock, onlinegdb)
Preparation before Practical Work 6 (Independent Learning (NF2F)):
[Student should prepare before Practical Work Session]

DEFINITION OF ARRAY

DIFFERENCE BETWEEN POINTER AND ARRAY IN C

DECLARING AN ONE DIMENSIONAL ARRAY


DECLARING MULTI-DIMENSIONAL ARRAY

GET THE OUTPUT OF THIS PROGRAM :

OUTPUT DISPLAY

Lecturer Verification & Approval,

(Sign & cop)


Date :
Exercise 1:
Student should key-in all the source code as shown below and compile/ run the program to get the
output. Please state the output result on the given column

#include <stdio.h>
int main ()
{
int n[ 10 ]; /* n is an array of 10 integers */
int i,j;

/* initialize elements of array n to 0 */


for ( i = 0; i < 10; i++ )
{
n[ i ] = i + 100; /* set element at location i to i + 100 */
}
/* output each array element's value */
for (j = 0; j < 10; j++ )
{
printf("Element[%d] = %d\n", j, n[j] );
}
return 0;
}

DISPLAY OUTPUT:

Lecturer Verification & Approval,

(Sign & cop)


Date :
Practical Assignments 1
Fixes Program 1: The following program contains 5 types of error which is syntax errors, run-time error,
Linker Error, misused of % operator and semantic error. Students need to verify the error and fix it before
their can get the correct output.

// Program to find the average of n numbers using arrays


#include <stdio.h>
int Main()
{
int marks[10), i, n, sum = 0, average;
printf("Enter number of elements: ");
scanf("%d", &n);
for(i=0; i<n; ++i)
{
printf("Enter number%d: ",i+1);
scanf("%d", &marks[i]);

// adding integers entered by the user to the sum variable


sum += marks[i];
int a, b, c;
a + b = c;
}
average = sum/0;
printf("Average = %%d", average);
return 0;
}

CORRECT PROGRAMMING :
DISPLAY OUTPUT :

Lecturer Verification & Approval,

(Sign & cop)


Date :
Practical Assignments 2
Complete Program:
Fill in the blanks to complete this program.
CORRECTION :

OUTPUT:

Lecturer Verification & Approval,

(Sign & cop)


Date :
PRACTICAL ASSIGNMENTS 3
Manipulates Program 1:
Write a program using Array to sum all the value of resistors in the given circuit. Build up the flowchart
and get the output for this program.

2kΩ
5kΩ

8kΩ

FLOWCHART :
PROGRAM:

OUTPUT:

Lecturer Verification & Approval,

(Sign & cop)


Date :
PRACTICAL ASSIGNMENTS 4
Display Program 1: Accessing Array Elements

Write the program and trace the output. Understand and get output of the program.

Program:

OUTPUT:

Lecturer Verification & Approval,

(Sign & cop)


Date :
PRACTICAL ASSIGNMENTS 5
Display Program 2: Store and Print Five Numbers in an Array

Write the program and trace the output. Understand and get output of the program.

Program:

FLOWCHART :
OUTPUT:

Lecturer Verification & Approval,

(Sign & cop)


Date :

DISCUSSION OF PRACTICAL WORK 6:


CONCLUSION OF PRACTICAL WORK 6:

Lecturer Verification & Approval,

(Sign & cop)


Date :

You might also like