Structures in c By Anand George.

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Introduction to Programming Lecture 15. In Today’s Lecture Pointers and Arrays Manipulations Pointers and Arrays Manipulations Pointers Expression Pointers.
Class Scope class Student { private: string id; string firstName, lastName; float gpa; public: void Read() { cin >> id >> firstName >> lastName >> gpa;
Introduction to Programming Lecture 39. Copy Constructor.
LCS Non-Dynamic Version int function lcs (x, y, i, j) begin if (i = 0) or (j = 0) return 0; else if (x[i] = y[j]) return lcs(x, y, i-1, j-1)+1; else return.
Sort the given string, without using string handling functions.
CSC141- Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 25 Thanks for Lecture Slides: Dr. Sadaf Tanveer Dr. Sadaf Tanveer,
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
Sorting Leena A PGT Comp SC KV No:2 Jalahalli. Introduction Common problem: sort a list of values, starting from lowest to highest. –List of exam scores.
Data Management and File Organization
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11: Structured Data.
Chapter 7 A Data Types – Structures Structures Structure: C++ construct that allows multiple variables to be grouped together Structure Declaration.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Passing Structure to function.  structure to function structure to function  Passing structure to function in C Passing structure to function in C 
Struct 1. Definition: Using struct to define a storage containing different types. For example it can contain int, char, float and array at the same time.
Structures (L30) u Syntax of a struct Declaration u Structure Variables u Accessing Members of Structures u Initialize Structure Variables u Array of Structures.
11/5/2016CS150 Introduction to Computer Science 1 Announcements  Assignment 6 due on Wednesday, December 3, 2003  Final Exam on Tuesday, December 9,
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
Struct COMP104 Struct / Slide 2 Motivation * Structures hold data that belong together. * Examples: n Student record  student id, name, major, gender,
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
Department of Electronic & Electrical Engineering IO reading and writing variables scanf printf format strings "%d %c %f"
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
1 11/30/05CS150 Introduction to Computer Science 1 Structs.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7. 12: Structures Starting Out with C++ Early Objects Eighth.
REEM ALAMER REVISION FOR C LANGUAGE COURSE. OUTPUTS int main (void) { int C1, C2; int *p1, *p2; C1 = 8; p1 = &C1; C2 = *p1 / 2 + 5; p2 = &C2; printf ("C1.
Chapter 6 Data Structures Program Development and Design Using C++, Third Edition.
SpringerLink Training Kit
Luminosity measurements at Hadron Colliders
From Word Embeddings To Document Distances
Choosing a Dental Plan Student Name
D. Phát triển thương hiệu
Điều trị chống huyết khối trong tai biến mạch máu não
BÖnh Parkinson PGS.TS.BS NGUYỄN TRỌNG HƯNG BỆNH VIỆN LÃO KHOA TRUNG ƯƠNG TRƯỜNG ĐẠI HỌC Y HÀ NỘI Bác Ninh 2013.
Nasal Cannula X particulate mask
Limits on Anomalous WWγ and WWZ Couplings from DØ
char first[10]="monkey"; char second[10]="fish"; char* keep;
LINKED LISTS.
using System; namespace Demo01 { class Program
Chapter 7: Introduction to Classes and Objects
CS150 Introduction to Computer Science 1
CSCI206 - Computer Organization & Programming
Structures.
Programming Languages and Paradigms
C++ Arrays.
Register Use Policy Conventions
Data Types – Structures
Lecture 9 Structure 1. Concepts of structure Pointers of structures
Data Types – Structures
ساختار ها در زبان C Structures in C.
Structure ការណែនាំអំពី Structure
Array of Structures A structure holds only one record But a record
Structures.
Data Structures and Algorithms
תירגול 9 אובייקטים.
Multidimensional Arrays
Insertion Sort Demo Sorting problem:
Programming Language C Language.
Starting to think about objects...
Structures In C Programming By Rajanikanth B.
Arrays.
Chapter 9: Pointers and String
Exercise 5 1. We learned bubble sort during class. This problem requires you to modify the code for bubble sorting method to implement the selection sorting.
Structure (i.e. struct) An structure creates a user defined data type
AP Java Unit 3 Strings & Arrays.
Characters and Strings
Pointer Arithmetic By Anand George.
CSCE 206 Lab Structured Programming in C
File handling in C By Anand George.
Structures, Unions, and Enumerations
Presentation transcript:

Structures in c By Anand George

Structures Very similar to arrays. Array contains same type of elements Structures contain different type of elements. Like a wallet or bag which has many different things in it.

Use of structure Think about in the program represent on a employee of a company. Had name, id, address. Name is a string type data. Id is integer type data Address is again string. Array wont fit Has to be a structure

Initialization struct myTestStruct { int a; char b; short c; int d; }; void main() myTestStruct mts = { 1, 2, 3, 4 }; }

Example struct Student { char name[100]; int studentId; char address[300]; };

Accessing elements Dot operator

Demo Accessing structure element with dot operator.

Demo Saving the name, id, and address of 5 students and printing it out. Sort the list with name of the student and print it.

Thank you