Download politeknik sultan mizan zainal abidin

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Array data structure wikipedia , lookup

Transcript
DEPARTMENT OF INFORMATION TECHNOLOGY AND
COMMUNICATION
Course Code : F4104
Course Name : ALGORITHM & DATA
STRUCTURE
Quiz :
1
Date :
Title :
OVERVIEW OF ALGORITHM AND DATA STRUCTURES
Objectives:
By the end of this lab, students should be able to:
1. Understand data structures and array
2. Define array of data structures.
3. Declare array of data structures.
4. Access array of data structures.
5. Write program using array of data structures.
Tools / Software:
- Desktop PC
- Microsoft Visual C++
Theory:
Data Structure
A way of storing data in a computer so that it can be use efficiently
A carefully chosen data structure will allow the most efficient algorithm to be used
A well-designed data structure allows a variety of critical operations to be performed,
Using as few resources, execution time, and memory space as possible
Algorithm
A sequence of instructions, often used for calculation and data processing
It is formally a type of effective method in which a list of well-defined instructions for
completing a task will:
- give an initial state, (INPUT)
- proceed through a well-defined series of successive states, (PROCESS)
- eventually terminate in an end-state, (OUTPUT)
Array
An array is a collection of data storage locations, each of which holds the same type of data.
Each storage location is called an element of the array.
DEPARTMENT OF INFORMATION TECHNOLOGY AND
COMMUNICATION
Course Code : F4104
Course Name : ALGORITHM & DATA
STRUCTURE
Quiz :
1
Date :
Title :
OVERVIEW OF ALGORITHM AND DATA STRUCTURES
Procedures:
1. Type the programs given below using Microsoft Visual C++ software.
#include<iostream.h>
#include<string.h>
#define SUBJEK 3
main()
{
struct Markah
{
float markah;
char kodSubj[5];
};
struct pelajar
{
char nama[30];
char noPendf[11];
char noKP[14];
struct Markah markah_pelajar[3];
}it;
//pelajar it;
cout<<"Nama Pelajar :";
cin>>it.nama;
cout<<"No pendaftaran :";
cin>>it.noPendf;
cout<<"No kad pengenalan :";
cin>>it.noKP;
for (int i=1; i<=SUBJEK; i++)
{
cout<<"Kod Subjek : ";//<< i <<":";
cin>>it.markah_pelajar[i].kodSubj;
cout<<"Masukkan Markah bagi " <<it.markah_pelajar[i].kodSubj
<<":";
cin>>it.markah_pelajar[i].markah;
}
cout<<"MARKAH PELAJAR"<<endl;
cout<<"NAMA PELAJAR : " <<it.nama<<endl;
cout<<"NO PENDAFTARAN : " <<it.noPendf<<endl;
cout<<"NO KAD PENGENALAN : " <<it.noKP<<endl;
for (int a=1; a<=SUBJEK; a++)
{
cout<<"Markah bagi " <<it.markah_pelajar[a].kodSubj <<":"
<<it.markah_pelajar[a].markah<<endl;
}
return 0;
}
DEPARTMENT OF INFORMATION TECHNOLOGY AND
COMMUNICATION
Course Code : F4104
Course Name : ALGORITHM & DATA
STRUCTURE
Quiz :
1
Date :
Title :
OVERVIEW OF ALGORITHM AND DATA STRUCTURES
2. Save the program as LAB2nopend.cpp.
Figure 1a
3. Compile and run the program.
Figure 1b
4. Test that output using a possible input. Write the output.
DEPARTMENT OF INFORMATION TECHNOLOGY AND
COMMUNICATION
Course Code : F4104
Course Name : ALGORITHM & DATA
STRUCTURE
Quiz :
1
Date :
Title :
OVERVIEW OF ALGORITHM AND DATA STRUCTURES
Figure 1c
Exercise:
Write a simple program that contained struct declaration to recorded information about
football team. The details needed to record such as team name, team manager, number of
winning, loosing and draw. The program also must have capabilities to display the
information.
(CLO2/CLO3: LD2:SO 1.2.9/1.3.7)
( 9 marks)
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
DEPARTMENT OF INFORMATION TECHNOLOGY AND
COMMUNICATION
Course Code : F4104
Course Name : ALGORITHM & DATA
STRUCTURE
Quiz :
1
Date :
Title :
OVERVIEW OF ALGORITHM AND DATA STRUCTURES
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Conclusion (Give the summary of this lab).
( 1 mark)
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________