










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











Grading Scale: Hw_Quiz 4 ^ >70: 100% of the grade forhomework ^ 50 -- 69: 90% of the gradefor homework ^ 40 -- 49: 80% of the gradefor homework ^ 30 -- 39: 60% of the gradefor the homework ^ 39 or below: at most 60% ofthe grade for the homework
20 18 16 14 12 10 8 6 4 2 0 >^
80^ > ^
50^ <=
^
Array: all elements have the
same type
, we
specify the
subscript
to pick the element we
want Structure: elements (members) can be of different types
, each member has a
name
int item_no; char
name[8]; float
price; float
discount; float
tax; }^ item1,
item2;
price
of^
%s^ is
%f\n”,
item1.name,
item1.price);
printf(“The
price
of^
%s”^
has
gone
up by
dollar.\n”);
item1.price
printf(“The
new
price
of^
%s^ is
%f\n”,
item1.name,
item1.price);
^
remember array cannot allocate memory, copy the values of the membersone by one ^ = only works for structures of compatible types(of the same type), more about this later ^ != and == and other operators do not work onstructures
item
{ int item_no;char name[8];float price;float discount;float tax; } ; struct item item1 =
{101, “gum”, 1.00, 0.25, 0.07}; struct item item2;item2 = item1;
struct
int item_no; char
name[8]; float
price; float
discount; float
tax; }^ Item;
^
Item grocery[10]; (where Item is a newly defined type) struct item inventory[100]; Inventory[3].price = 4.95; ^ Structures may contain arrays and structures asmembers^ ^
Item.name in the previous example ^ Initializing an array of structures^ ^
Const struct dialing_code country_codes[] ={{“Argentina”, 54}, {“Bangladesh”,880}, …..{“UnitedState”, 1 }};