CS 202 Computer Science II Lab Fall 2009 October 15.

Slides:



Advertisements
Similar presentations
WALT: Know the months of the year poem. Answer questions about the months.
Advertisements

DOT 1 January , 1990 DOT 2 July 23 - August 3, 1990.
Chubaka Producciones Presenta :.
2012 JANUARY Sun Mon Tue Wed Thu Fri Sat
January 2012 Monday Tuesday Wednesday Thursday Friday Sat/ Sun / /8 14/15 21/22 28/
/3024/ SUN MON TUE WED THU FRI SAT JANUARY 2011 February 2011 SMTWTFS
P Pathophysiology Calendar. SundayMondayTuesdayWednesdayThursdayFridaySaturday January 2012.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 10 - Structures, Unions, Bit Manipulations, and Enumerations Outline 10.1Introduction 10.2Structure.
Chicas, este calendario si es pa' nosotras !!!!!.
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSAT/SUN Note: You can print this template to use as a wall calendar. You can also copy the slide for any month to add.
2007 Monthly Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.

CCSA 221 Programming in C CHAPTER 14 MORE ON DATA TYPES 1 ALHANOUF ALAMR.
WORD JUMBLE. Months of the year Word in jumbled form e r r f b u y a Word in jumbled form e r r f b u y a february Click for the answer Next Question.
Weather Fatima Emirova.
DATE POWER 2 INCOME JANUARY 100member X 25.00P2, FEBRUARY 200member X 25.00P5, MARCH 400member X 25.00P10, APRIL 800member.
Calendar for 2011 Months of the Year with Holidays.
2011 Calendar Important Dates/Events/Homework. SunSatFriThursWedTuesMon January
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSAT/SUN 30 June1 July2345/65/ / / / August2/32/3.
CALENDAR 2015: “THIS PROJECT HAS BEEN FUNDED WITH SUPPORT FROM THE EUROPEAN COMMISSION. THIS PUBLICATION [COMMUNICATION] REFLECTS THE VIEWS ONLY OF THE.
TEMPORAL VISUALIZATION OF DATA FROM THE FRENCH SENTINEL NETWORK.
July 2007 SundayMondayTuesdayWednesdayThursdayFridaySaturday
Dictation practice 2nd Form Ms. Micaela-Ms. Verónica.
JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER
JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER
TIMELINES PHOTOS This is an example text
TIMELINES PHOTOS This is an example text
McDonald’s Kalender 2009.
McDonald’s Kalender 2009.
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
13-block rotation schedule
Windows Programming Lecture 04
1   1.テキストの入れ替え テキストを自由に入れ替えることができます。 フチなし全面印刷がおすすめです。 印刷のポイント.
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
McDonald’s Kalender 2009.
January Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
Data Structures.
Problem Gambling Clicks to Opgr.org
2300 (11PM) September 21 Blue line is meridian..
January MON TUE WED THU FRI SAT SUN
McDonald’s calendar 2007.
1 - January - Sun Mon The Wed Thu Fri Sat
Teacher name August phone: Enter text here.
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
Calendar.
Circle Chart Template Process Name.
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
February 2007 Note: Source:.
| January Sunday Monday Tuesday Wednesday Thursday Friday
Calendar Time.
January MON TUE WED THU FRI SAT SUN
MONTHS OF THE YEAR January February April March June May July August
S M T W F S M T W F
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
McDonald’s calendar 2007.
1 January 2018 Sun Mon Tue Wed Thu Fri Sat
Habitat Changes and Fish Migration
January Monday Tuesday Wednesday Thursday Friday Saturday Sunday 30 31
2015 January February March April May June July August September
Habitat Changes and Fish Migration
S M T W F S M T W F
S M T W F S M T W F
Exercise 6 – Compound Types und Kontrollfluss
Presentation transcript:

CS 202 Computer Science II Lab Fall 2009 October 15

Data Types Structure Typedef Union Enum

Data Types Structure struct product { int weight; float price; } apple; apple.price

Data Types Structure struct product { int weight; float price; } apple, banana, melon; apple.price banana.weight

Data Types Structure struct product { int weight; float price; } fruit[10]; fruit[5].price fruit[5].weight

Data Types Pointer to Structure *(apple.weight) Value pointed by member weight of object apple *apple.weight (*apple).weight Member weight of object pointed by apple apple->weight Member weight of object apple apple.weight EquivalentWhat is evaluated Expression

Data Types Nesting Structure struct movies_t { string title; int year; }; struct friends_t { string name; string ; movies_t favorite_movie; } charlie, maria; friends_t * pfriends = &charlie; charlie.name maria.favorite_movie.title charlie.favorite_movie.year pfriends->favorite_movie.year

Data Types Typedef – Defined data types typedef char C; typedef unsigned int WORD; typedef char * pChar; typedef char field [50]; C mychar, anotherchar, *ptc1; WORD myword; pChar ptc2; field name;

Data Types Union – allows same portion of memory to be accessed as different data types union myTest { char c; int i; float f; } myVar; myVar.c myVar.i myVar.f

Data Types Union union mix_t { long l; struct { short hi; short lo; } s; char c[4]; } mix; 0xA70x430x510x12 mix mix.l mix.s.himix.s.lo mix.c[0]mix.c[1]mix.c[2]mix.c[3]

Comparison Between Struct and Union in terms of Memory Space #include using namespace std; struct myStruct{ bool a; bool c; char b[4]; } A; int main(){ cout<<sizeof(A)<<'\n'; return 0; } Answer: >>6 #include using namespace std; union myUnion{ bool a; bool c; char b[4]; } A; int main(){ cout<<sizeof(A)<<'\n'; return 0; } Answer: >>4

Data Types Anonymous Union struct { char title[50]; char author[50]; union { float dollars; int yens; }; } book; struct { char title[50]; char author[50]; union { float dollars; int yens; } price; } book; structure with anonymous union structure with regular union book.price.dollars book.price.yens book.dollars book.yens

Data Types Enum – Enumerations create new data types enum colors_t {black, blue, green, cyan, red, purple, yellow, white}; colors_t mycolor; … mycolor = blue; if (mycolor == green) mycolor = red; enum months_t { january, february, march, april, may, june, july, august, september, october, november, december } myMonth; enum months_t { january=1, february, march, april, may, june, july, august, september, october, november, december } myMonth; myMonth = January; /* myMonth=0 */ myMonth = february; /* myMonth=1 */ myMonth = march; /* myMonth=2 */ myMonth = January; /* myMonth=1 */ myMonth = february; /* myMonth=2 */ myMonth = march; /* myMonth=3 */

Questions?

Data Types #include using namespace std; struct myStruct{ bool a; bool c; char b[4]; } A; int main(){ cout<<sizeof(A)<<'\n'; return 0; }