Computer Programming II

Slides:



Advertisements
Similar presentations
UNIT IV.
Advertisements

Structures. An array allows us to store a collection of variables However, the variables must be of the same type to be stored in an array E.g. if we.
1 Lecture 24 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
Structures EE2372 Software Design I Dr. Gerardo Rosiles.
More Storage Structures A Data Type Defined by You Characteristics of a variable of a specific ‘data type’ has specific values or range of values that.
Structured Data Types array array union union struct struct class class.
CS1201: Programming Language 2 Structure By: Nouf Almunyif.
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
CECS 130 EXAM 2.  Function Prototype Syntax return-type function_name ( arg_type arg1,..., arg_type argN);  Function Prototypes tell you the data type.
Array, Structure and Union
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Linked List Chapter Data Abstraction separates the logical properties of a data type from its implementation LOGICAL PROPERTIES – What are the.
+ Structures and Unions. + Introduction We have seen that arrays can be used to represent a group of data items that belong to the same type, such as.
Lab 8. Declaring and Creating Arrays in One Step datatype[] arrayRefVar = new datatype[arraySize]; double[] myList = new double[10];
CSE 251 Dr. Charles B. Owen Programming in C1 structs Aggregating associated data into a single variable Box width length height Circle radius int main()
STRUCTURES. INTRODUCTION A structure is same as that of records. It stores related information about an entity. Structure is basically a user defined.
Chapter 6. Character String Types It is one in which the values consists of sequences of characters. How to Define a variable contain a string? In a programming.
Chapter 6 Data Structures Program Development and Design Using C++, Third Edition.
Andrew(amwallis) Classes!
Chapter 8 Multidimensional Arrays
CO1401 Program Design and Implementation
CS1010 Programming Methodology
Chapter 10-1: Structure.
Structures and Unions.
[Array, Array, Array, Array]
Programming Structures.
Visit for more Learning Resources
Motivations Thus far, you have used one-dimensional arrays to model linear collections of elements. You can use a two-dimensional array to represent a.
Module 2 Arrays and strings – example programs.
Prepared By: G.UshaRani B.Pranalini A.S.Lalitha
Buy book Online -
Lecture 9 Structure 1. Concepts of structure Pointers of structures
CSC 253 Lecture 13.
Learning Objectives Structures Structure types
Structures A Structure is a collection of related data items, possibly of different types. A structure type in C++ is called struct. A struct is heterogeneous.
CS150 Introduction to Computer Science 1
Structures December 6, 2017.
Structures putting data together.
Structure ការណែនាំអំពី Structure
Chapter 10: Records (structs)
Chapter 8 Multidimensional Arrays
Lecture 18 Arrays and Pointer Arithmetic
Pointer to Structures Lesson xx
Chapter 8 Multidimensional Arrays
Arrays .
Structured Data Types array union struct class.
Data Structures.
Topics discussed in this section:
[Array, Array, Array, Array]
Multidimensional Arrays
Objectives In this chapter, you will: - Learn about records (structs) - Examine operations on a struct - Manipulate data using a struct - Learn about the.
Chapter 10 Structures and Unions
CISC181 Introduction to Computer Science Dr
Structure.
Thanachat Thanomkulabut
Chapter 8 Multidimensional Arrays
By Yogesh Neopaney Assistant Professor Department of Computer Science
C Programming Lecture-13 Structures
Structures In C Programming By Rajanikanth B.
C Programming Pointers
CS149D Elements of Computer Science
C Programming Lecture-14 Unions
READING AND PRINTING MATRICES (with functions)
Chapter 7 Multidimensional Arrays
CS148 Introduction to Programming II
Chapter 8 Multidimensional Arrays
Structures Chapter 4.
Structures Declarations CSCI 230
Week 7 - Monday CS 121.
Exercise 6 – Compound Types und Kontrollfluss
Presentation transcript:

Computer Programming II Lecture 3

Data Structures: Definition: A data structure is a group of data elements grouped together under one name. These data elements, known as members, can have different types and different lengths.

Data Structures: Data structures can be declared in C++ using the following syntax: struct structure_name { data_type1 member_name1; data_type2 member_name2; data_type3 member_name3; . . } ;

Data Structures: For example: struct product { int weight; double price; } ;

Data Structures: Initializing a Structure: for example, the following date structure has been declared: struct date { int day, month, year; }; A date variable can now be defined and initialized by following the variable name with the assignment operator and an initialization list, as shown here: date birthday = {23, 8, 1983};

Data Structures: Declaring Structure Variables: There are two ways to declare variables of structures: 1- Declaring Structure Variables at Definition: Syntax: struct type_name { data_type1 member_name1; data_type2 member_name2; . . } variable_name ; For example: struct product { int weight; double price; } apple, banana, melon ;

Data Structures: 2- Declaring Structure Variables After Definition: Synatx: structure_name variable_name; For example: struct product { int weight; double price; } ; product apple; product banana , melon;

Data Structures: Accessing Structure Members: To access any member of a structure, we use the member access operator (.). The member access operator is coded between the structure variable name and the structure member that we wish to access. For example: apple.weight apple.price banana.weight banana.price melon.weight melon.price

Data Structures: - Write a program that used to print the student data (Using structure). Note : The first student : Name: Sarah Age: 19 The second student : Name: Maha Age: 20 The third student : Name: Nuha Age: 22

Data Structures: - Write a program that used to read the student data for three students which are (student_number , student_name and student_tel) and print it .(Using structure).

Structure and array: - Write a program to enter the addresses of five customers where the address includes (customer number, customer name and city).

Structure and array:

Structure and function: - Write a program to read the student data for two students and print it. (Using structure and function) Note : Student data includes(student number , student name and the department)

Structure and function:

Structure and function: