SlideShare une entreprise Scribd logo
1  sur  16
main( ) 
{ 
int m, y ; 
long int normaldays ; 
long int totaldays ; 
scanf ( ”%d%d”, &m, &y ) ; 
printf ( ”Enter month and year” ) ; 
normaldays = ( y - 1 ) * 365 L ; 
leapdays = ( y - 1 ) / 4 - ( y - 1 ) / 100 
+ ( y - 1 ) / 400 ; 
totaldays = normaldays + 
leapdays . . ; 
} 
8 1999 
1/8/1999 - ? 
1/1/1 - Mon 
1/1/1999 - ? 
1/1/1 to 
31/12/1998 
  
x % 7 
1/8/1999 - ? 
1/1/1 to 
31/7/1999  
1/1/1 to 
31/12/1998 
+1/1/1999 to 
31/7/1999 
x % 7 
CCaalleennddaarr 
int leapdays ;
main( ) 
{ 
......CCaalleennddaarr 
{ 31, 28, 31, 30, 31, 30, 
31, 31, 30, 31, 30, 31 } ; 
int days[ ] = 
.i n.t i, s ; int firstday ; . . 
totaldays = normaldays + 
leapdays ; 
s = 0 ; 
for ( i = 0 ; i = ; i++ ) 
s = s + 
totaldays += s ; 
firstday = totaldays % 7 ; 
. . 
} 
m - 2 
days[ i ] ; 
1/1/1 to 31/12/1998 
totaldays 
1/1/1999 to 31/7/1999 
31 + 28 + 31 + 30 
+ 31 + 30 + 31
......CCaalleennddaarr 
( ) 
main( ) 
{ 
{ 31, 28, 31, 30, 31, 30, 
31, 31, 30, 31, 30, 31 } ; 
int days[ ] = 
.. .. 
totaldays = normaldays + leapdays ; 
if ( ( y % 400 == 0 ) || ) 
days[ 1 ] = 29 ; 
s = 0 ; 
for ( i = 0 ; i = ; i++ ) 
s = s + 
. . 
} 
m - 2 
days[ i ] ; 
y % 100 != 0  y % 4 == 0 
totaldays += s ; 
firstday = totaldays % 7 ;
SSccrreeeenn 
August 1999 
10 
20 26 32 38 44 50 56 
Mon - - -Tue - - -Wed - - -Thu- - -Fri - - -Sat - - -Sun
10 
20 26 32 
Mon - - -Tue - - -Wed--- 
......CCaalleennddaarr 
main( ) 
{ 
.. .. 
char *months[ ] = { ”January”, ”February”, … } ; 
totaldays += s ; 
firstday = totaldays % 7 ; 
col = 20 + firstday * 6 ; 
clrscr( ) ; 
gotorc ( 8 , 3 5 ) ; 
printf ( ”%s %d”, months [ m - 1 ], y ) ; 
} 
gotorc ( 10 
, 3 5 ) ; 
printf ( ”Mon Tue Wed Thu Fri Sat Sun” 
) ;
......CCaalleennddaarr 
main( ) 
{ 
i n t d a y s [ ] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, … } ; 
/* print month year */ 
/* print days */ 
for ( i = 1 ; i = days[ m - 1 ] ; i++ ) 
{ 
gotorc ( r o w , c o l ) ; 
printf ( ”%d”, i ) ; 
col = col + 6 ; 
if ( col  56 ) 
{ 
row++ ; col = 20 ; 
} } } 
10 
20 26 32 
Mon - - -Tue - - -Wed--- 
row = 12 ;
main( ) 
{ . . 
scanf ( ”%d%d”, m, y ) ; 
while ( 1 ) 
{ 
normaldays ____ = ( y - 1 ) * 365L ; 
c__a__lender 
gotorc ( 20, 35 
) ; 
printf ( ”Rt-Next mth…” ) ; 
ch = getkey( ) ; 
switch ( ch ) 
{ 
case 77 : 
m++ ; 
if ( m  12 ) 
{ 
y++ ; m = 1 ; 
__}__ } 
} 
} 
......CCaalleennddaarr 
Next year 
Prev. 
mth Next 
 
  
Prev. year 
mth
main( ) 
{ 
{ 31, 28, 31, 30, 31, 30, 
31, 31, 30, 31, 30, 31 } ; 
int days[ ] = 
scanf ( ”%d%d”, m, y ) ; 
while ( 1 ) 
{ 
normaldays = 
totaldays = 
leapdays = 
if ( y % 400 = = 0 ) || ( y % 100 ! = 0  y % 4 = = 0 ) ) 
days[ 1 ] = 29 ; 
else 
. . days[ 1 ] = 28 ; 
} } 
9, 1998 
9, 2000 
9, 1700 
9, 1752 
- 30 
- 30 
- 30 
- 16 
......CCaalleennddaarr
TTeerrmmiinnoollooggyy 
Fields 
Record 
Database 
Name Age Salary 
’’AA’’ 2233 44000000..5500 
’X’ 27 5000.00 
’Y’ 28 6000.75
main( ) 
{ 
char n[ ] = { ’A’, ’X’, ’Y’, ’0’ } ; 
int a[ ] = { 23, 27, 28 } ; 
float s[ ] = { 4000.50, 5000.00, 6000.75 } ; 
int i ; 
for ( i = 0 ; i = 2 ; i++ ) 
printf ( ”%c %d %f”, n[ i ], a[ i ], s[ i ] ) ; 
} 
HHaannddlliinngg DDaattaa
main( ) 
{ 
struct employee 
{ 
char n ; 
int a ; 
float s ; 
} ; 
struct employee e 1 = 
{ ’A’, 23, 4000.50 } ; 
struct employee e2 = { ’X’, 27, 5000.00 } ; 
struct employee e3 = { ’Y’, 28, 6000.75 } ; 
printf ( ”%c %d %f”, n, a, s ) ; 
e1. e1. e1. 
printf ( ”%c %d %f”, e2.n, e2.a, e2.s ) ; 
printf ( ”%c %d %f”, e3.n, e3.a, e3.s ) ; 
} 
. 
 
structure 
operators 
SSttrruuccttuurreess
main( ) 
{ 
AArrrraayy ooff SSttrruuccttuurreess 
struct employee 
{ 
char n ; 
int a ; 
float s ; 
} ; 
struct employee e[ ] 
= { 
{ ’A’, 23, 4000.50 } , 
{ ’X’, 27, 5000.00 } , 
{ ’Y’, 28, 6000.75 } 
} ; 
int i ; 
for ( i = 0 ; i = 2 ; i++ ) 
printf ( ”%c %d %f”, e [ i ] 
} 
.n, e[ i ].a, e[ i ].s ) ;
Keyword eemmppllooyyeeee 
Structure 
name/ 
struct 
{ 
tag 
char n ; 
int a ; 
float s ; 
} ; 
struct employee e1, e2, e[ 10 ] ; 
Structure elements/ 
members 
Structure 
variables Array of 
structures
Conclusion 
A structure is usually a collection of 
dissimilar elements. 
Structure elements are always stored in 
adjacent memory locations. 
struct employee e[ 3 ] ; 
A 23 400.50 X 27 500.00 Y 28 
600.75 
401 408 415
AArrrraayy ooff SSttrruuccttuurreess 
struct employee e[ ] = { ... } ; 
char *p ; 
Ptr. to 
structure 
struct employee e[ 3 ] ; 
A 23 400.50 X 27 500.00 Y 600.75 
401 408 415 
q = e ; r = e ; 
p = e ; 
p++ ; 
printf ( ”%u”, q ) ; 
28 
struct employee *q ; 
struct employee (*r )[3] ; 
q++ ; r++ ; 
printf ( ”%u”, p ) ; 
printf ( ”%u”, r ) ; 
440022 
440088 
442222 
Array of 
ptrs.
228822-- 228888 
CChhaapptteerr 99

Contenu connexe

Tendances

Tabela derivadas-e-integrais
Tabela derivadas-e-integraisTabela derivadas-e-integrais
Tabela derivadas-e-integraismariasousagomes
 
8.2 integration by parts
8.2 integration by parts8.2 integration by parts
8.2 integration by partsdicosmo178
 
Practica productos notables
Practica productos notablesPractica productos notables
Practica productos notablesLina Ari
 
Intro To Gradient Descent in Javascript
Intro To Gradient Descent in JavascriptIntro To Gradient Descent in Javascript
Intro To Gradient Descent in JavascriptK. Matthew Dupree
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmKapil Pandit
 
Better performance through Superscalarity
Better performance through SuperscalarityBetter performance through Superscalarity
Better performance through SuperscalarityMårten Rånge
 
Include stdio. wps office (1)
Include  stdio. wps office (1)Include  stdio. wps office (1)
Include stdio. wps office (1)NilayChavhan
 
R scatter plots
R scatter plotsR scatter plots
R scatter plotsAbhik Seal
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsKandarp Tiwari
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicalsManoj Chauhan
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignmentashikul akash
 

Tendances (18)

Tabela derivadas-e-integrais
Tabela derivadas-e-integraisTabela derivadas-e-integrais
Tabela derivadas-e-integrais
 
8.2 integration by parts
8.2 integration by parts8.2 integration by parts
8.2 integration by parts
 
Practica productos notables
Practica productos notablesPractica productos notables
Practica productos notables
 
Página 115
Página 115Página 115
Página 115
 
Ch13 16
Ch13 16Ch13 16
Ch13 16
 
Intro To Gradient Descent in Javascript
Intro To Gradient Descent in JavascriptIntro To Gradient Descent in Javascript
Intro To Gradient Descent in Javascript
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
 
Problemas de funciones
Problemas de funcionesProblemas de funciones
Problemas de funciones
 
Proga 0601
Proga 0601Proga 0601
Proga 0601
 
Better performance through Superscalarity
Better performance through SuperscalarityBetter performance through Superscalarity
Better performance through Superscalarity
 
Include stdio. wps office (1)
Include  stdio. wps office (1)Include  stdio. wps office (1)
Include stdio. wps office (1)
 
Htdp27.key
Htdp27.keyHtdp27.key
Htdp27.key
 
R scatter plots
R scatter plotsR scatter plots
R scatter plots
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
2D array
2D array2D array
2D array
 
Resumen potencias
Resumen potenciasResumen potencias
Resumen potencias
 

En vedette

C language Online Training in Hyderabad
C language Online Training in HyderabadC language Online Training in Hyderabad
C language Online Training in HyderabadUgs8008
 
Analog I/O in PIC16F877A
Analog I/O in PIC16F877AAnalog I/O in PIC16F877A
Analog I/O in PIC16F877AMohamed Bedair
 
Intro to cprogramming
Intro to cprogrammingIntro to cprogramming
Intro to cprogrammingskashwin98
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDYDATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language CourseVivek chan
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDLWingston
 

En vedette (20)

C language Online Training in Hyderabad
C language Online Training in HyderabadC language Online Training in Hyderabad
C language Online Training in Hyderabad
 
Vcs29
Vcs29Vcs29
Vcs29
 
Vcs28
Vcs28Vcs28
Vcs28
 
B-TREE PREPARED BY M V BRAHMANANDA REDDY
B-TREE PREPARED BY M V BRAHMANANDA REDDYB-TREE PREPARED BY M V BRAHMANANDA REDDY
B-TREE PREPARED BY M V BRAHMANANDA REDDY
 
Data representation UNIT-1
Data representation UNIT-1Data representation UNIT-1
Data representation UNIT-1
 
Vcs16
Vcs16Vcs16
Vcs16
 
DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1
 
Analog I/O in PIC16F877A
Analog I/O in PIC16F877AAnalog I/O in PIC16F877A
Analog I/O in PIC16F877A
 
Intro to cprogramming
Intro to cprogrammingIntro to cprogramming
Intro to cprogramming
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDYDATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
 
Digital i o
Digital i oDigital i o
Digital i o
 
Intrerfacing i
Intrerfacing iIntrerfacing i
Intrerfacing i
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
AVL TREE PREPARED BY M V BRAHMANANDA REDDY
AVL TREE PREPARED BY M V BRAHMANANDA REDDYAVL TREE PREPARED BY M V BRAHMANANDA REDDY
AVL TREE PREPARED BY M V BRAHMANANDA REDDY
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notesM v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
C language
C languageC language
C language
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDL
 
Embedded System Presentation
Embedded System PresentationEmbedded System Presentation
Embedded System Presentation
 

Similaire à Vcs22 (20)

8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
 
programs
programsprograms
programs
 
Vcs17
Vcs17Vcs17
Vcs17
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdf
Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdfDate.h#ifndef DateFormat#define DateFormat#includetime.h.pdf
Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdf
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
C programs
C programsC programs
C programs
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
 
Vcs9
Vcs9Vcs9
Vcs9
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
Arrays
ArraysArrays
Arrays
 
Need to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdfNeed to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdf
 
Project presentation(View calender)
Project presentation(View calender)Project presentation(View calender)
Project presentation(View calender)
 
array2d.ppt
array2d.pptarray2d.ppt
array2d.ppt
 
C programs
C programsC programs
C programs
 
Vcs5
Vcs5Vcs5
Vcs5
 
数式処理ソフトMathematicaで数学の問題を解く
数式処理ソフトMathematicaで数学の問題を解く数式処理ソフトMathematicaで数学の問題を解く
数式処理ソフトMathematicaで数学の問題を解く
 
array
arrayarray
array
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 

Plus de Malikireddy Bramhananda Reddy (17)

Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
C SLIDES PREPARED BY M V B REDDY
C SLIDES PREPARED BY  M V B REDDYC SLIDES PREPARED BY  M V B REDDY
C SLIDES PREPARED BY M V B REDDY
 
C AND DATASTRUCTURES PREPARED BY M V B REDDY
C AND DATASTRUCTURES PREPARED BY M V B REDDYC AND DATASTRUCTURES PREPARED BY M V B REDDY
C AND DATASTRUCTURES PREPARED BY M V B REDDY
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
C LANGUAGE NOTES
C LANGUAGE NOTESC LANGUAGE NOTES
C LANGUAGE NOTES
 
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
C notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit orderC notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit order
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
 
Vcs26
Vcs26Vcs26
Vcs26
 
Vcs24
Vcs24Vcs24
Vcs24
 
Vcs23
Vcs23Vcs23
Vcs23
 
Vcs21
Vcs21Vcs21
Vcs21
 
Vcs20
Vcs20Vcs20
Vcs20
 
Vcs19
Vcs19Vcs19
Vcs19
 
Vcs15
Vcs15Vcs15
Vcs15
 
Vcs14
Vcs14Vcs14
Vcs14
 
Vcs12
Vcs12Vcs12
Vcs12
 
Vcs8
Vcs8Vcs8
Vcs8
 
Vcs6
Vcs6Vcs6
Vcs6
 

Vcs22

  • 1. main( ) { int m, y ; long int normaldays ; long int totaldays ; scanf ( ”%d%d”, &m, &y ) ; printf ( ”Enter month and year” ) ; normaldays = ( y - 1 ) * 365 L ; leapdays = ( y - 1 ) / 4 - ( y - 1 ) / 100 + ( y - 1 ) / 400 ; totaldays = normaldays + leapdays . . ; } 8 1999 1/8/1999 - ? 1/1/1 - Mon 1/1/1999 - ? 1/1/1 to 31/12/1998 x % 7 1/8/1999 - ? 1/1/1 to 31/7/1999 1/1/1 to 31/12/1998 +1/1/1999 to 31/7/1999 x % 7 CCaalleennddaarr int leapdays ;
  • 2. main( ) { ......CCaalleennddaarr { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ; int days[ ] = .i n.t i, s ; int firstday ; . . totaldays = normaldays + leapdays ; s = 0 ; for ( i = 0 ; i = ; i++ ) s = s + totaldays += s ; firstday = totaldays % 7 ; . . } m - 2 days[ i ] ; 1/1/1 to 31/12/1998 totaldays 1/1/1999 to 31/7/1999 31 + 28 + 31 + 30 + 31 + 30 + 31
  • 3. ......CCaalleennddaarr ( ) main( ) { { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ; int days[ ] = .. .. totaldays = normaldays + leapdays ; if ( ( y % 400 == 0 ) || ) days[ 1 ] = 29 ; s = 0 ; for ( i = 0 ; i = ; i++ ) s = s + . . } m - 2 days[ i ] ; y % 100 != 0 y % 4 == 0 totaldays += s ; firstday = totaldays % 7 ;
  • 4. SSccrreeeenn August 1999 10 20 26 32 38 44 50 56 Mon - - -Tue - - -Wed - - -Thu- - -Fri - - -Sat - - -Sun
  • 5. 10 20 26 32 Mon - - -Tue - - -Wed--- ......CCaalleennddaarr main( ) { .. .. char *months[ ] = { ”January”, ”February”, … } ; totaldays += s ; firstday = totaldays % 7 ; col = 20 + firstday * 6 ; clrscr( ) ; gotorc ( 8 , 3 5 ) ; printf ( ”%s %d”, months [ m - 1 ], y ) ; } gotorc ( 10 , 3 5 ) ; printf ( ”Mon Tue Wed Thu Fri Sat Sun” ) ;
  • 6. ......CCaalleennddaarr main( ) { i n t d a y s [ ] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, … } ; /* print month year */ /* print days */ for ( i = 1 ; i = days[ m - 1 ] ; i++ ) { gotorc ( r o w , c o l ) ; printf ( ”%d”, i ) ; col = col + 6 ; if ( col 56 ) { row++ ; col = 20 ; } } } 10 20 26 32 Mon - - -Tue - - -Wed--- row = 12 ;
  • 7. main( ) { . . scanf ( ”%d%d”, m, y ) ; while ( 1 ) { normaldays ____ = ( y - 1 ) * 365L ; c__a__lender gotorc ( 20, 35 ) ; printf ( ”Rt-Next mth…” ) ; ch = getkey( ) ; switch ( ch ) { case 77 : m++ ; if ( m 12 ) { y++ ; m = 1 ; __}__ } } } ......CCaalleennddaarr Next year Prev. mth Next Prev. year mth
  • 8. main( ) { { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ; int days[ ] = scanf ( ”%d%d”, m, y ) ; while ( 1 ) { normaldays = totaldays = leapdays = if ( y % 400 = = 0 ) || ( y % 100 ! = 0 y % 4 = = 0 ) ) days[ 1 ] = 29 ; else . . days[ 1 ] = 28 ; } } 9, 1998 9, 2000 9, 1700 9, 1752 - 30 - 30 - 30 - 16 ......CCaalleennddaarr
  • 9. TTeerrmmiinnoollooggyy Fields Record Database Name Age Salary ’’AA’’ 2233 44000000..5500 ’X’ 27 5000.00 ’Y’ 28 6000.75
  • 10. main( ) { char n[ ] = { ’A’, ’X’, ’Y’, ’0’ } ; int a[ ] = { 23, 27, 28 } ; float s[ ] = { 4000.50, 5000.00, 6000.75 } ; int i ; for ( i = 0 ; i = 2 ; i++ ) printf ( ”%c %d %f”, n[ i ], a[ i ], s[ i ] ) ; } HHaannddlliinngg DDaattaa
  • 11. main( ) { struct employee { char n ; int a ; float s ; } ; struct employee e 1 = { ’A’, 23, 4000.50 } ; struct employee e2 = { ’X’, 27, 5000.00 } ; struct employee e3 = { ’Y’, 28, 6000.75 } ; printf ( ”%c %d %f”, n, a, s ) ; e1. e1. e1. printf ( ”%c %d %f”, e2.n, e2.a, e2.s ) ; printf ( ”%c %d %f”, e3.n, e3.a, e3.s ) ; } . structure operators SSttrruuccttuurreess
  • 12. main( ) { AArrrraayy ooff SSttrruuccttuurreess struct employee { char n ; int a ; float s ; } ; struct employee e[ ] = { { ’A’, 23, 4000.50 } , { ’X’, 27, 5000.00 } , { ’Y’, 28, 6000.75 } } ; int i ; for ( i = 0 ; i = 2 ; i++ ) printf ( ”%c %d %f”, e [ i ] } .n, e[ i ].a, e[ i ].s ) ;
  • 13. Keyword eemmppllooyyeeee Structure name/ struct { tag char n ; int a ; float s ; } ; struct employee e1, e2, e[ 10 ] ; Structure elements/ members Structure variables Array of structures
  • 14. Conclusion A structure is usually a collection of dissimilar elements. Structure elements are always stored in adjacent memory locations. struct employee e[ 3 ] ; A 23 400.50 X 27 500.00 Y 28 600.75 401 408 415
  • 15. AArrrraayy ooff SSttrruuccttuurreess struct employee e[ ] = { ... } ; char *p ; Ptr. to structure struct employee e[ 3 ] ; A 23 400.50 X 27 500.00 Y 600.75 401 408 415 q = e ; r = e ; p = e ; p++ ; printf ( ”%u”, q ) ; 28 struct employee *q ; struct employee (*r )[3] ; q++ ; r++ ; printf ( ”%u”, p ) ; printf ( ”%u”, r ) ; 440022 440088 442222 Array of ptrs.