SlideShare a Scribd company logo
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

More Related Content

PPTX
Gauss in java
DOCX
PythonArtCode
PDF
Regras diferenciacao
DOCX
Interpolation graph c++
PDF
Tabela completa de derivadas e integrais
DOCX
Caropro
PDF
2Bytesprog2 course_2014_c9_graph
PDF
ECMAScript 6 major changes
Gauss in java
PythonArtCode
Regras diferenciacao
Interpolation graph c++
Tabela completa de derivadas e integrais
Caropro
2Bytesprog2 course_2014_c9_graph
ECMAScript 6 major changes

What's hot (18)

PDF
Tabela derivadas-e-integrais
PPTX
8.2 integration by parts
DOCX
Practica productos notables
PDF
PDF
Ch13 16
PDF
Intro To Gradient Descent in Javascript
DOCX
Wap in c to draw a line using DDA algorithm
PDF
Problemas de funciones
PDF
Proga 0601
PPTX
Better performance through Superscalarity
DOCX
Include stdio. wps office (1)
PDF
Htdp27.key
DOCX
R scatter plots
DOCX
Computer Graphics Lab File C Programs
PPT
computer graphics practicals
DOCX
Numerical Method Assignment
PDF
2D array
PDF
Resumen potencias
Tabela derivadas-e-integrais
8.2 integration by parts
Practica productos notables
Ch13 16
Intro To Gradient Descent in Javascript
Wap in c to draw a line using DDA algorithm
Problemas de funciones
Proga 0601
Better performance through Superscalarity
Include stdio. wps office (1)
Htdp27.key
R scatter plots
Computer Graphics Lab File C Programs
computer graphics practicals
Numerical Method Assignment
2D array
Resumen potencias
Ad

Viewers also liked (20)

PPTX
C language Online Training in Hyderabad
PPT
B-TREE PREPARED BY M V BRAHMANANDA REDDY
PPT
Data representation UNIT-1
PPT
DATASTRUCTURES UNIT-1
PDF
Analog I/O in PIC16F877A
PPTX
Intro to cprogramming
PPT
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
PPT
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
PDF
Digital i o
PDF
Intrerfacing i
PPTX
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
PPT
AVL TREE PREPARED BY M V BRAHMANANDA REDDY
PDF
M v bramhananda reddy dsa complete notes
PPSX
Complete C programming Language Course
PDF
C language
PPTX
C game programming - SDL
PPT
Embedded System Presentation
C language Online Training in Hyderabad
B-TREE PREPARED BY M V BRAHMANANDA REDDY
Data representation UNIT-1
DATASTRUCTURES UNIT-1
Analog I/O in PIC16F877A
Intro to cprogramming
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
Digital i o
Intrerfacing i
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
AVL TREE PREPARED BY M V BRAHMANANDA REDDY
M v bramhananda reddy dsa complete notes
Complete C programming Language Course
C language
C game programming - SDL
Embedded System Presentation
Ad

Similar to Vcs22 (20)

PDF
C- Programming Assignment practice set 2 solutions
PDF
DSC Lab Manual fffffffffffffffffffff.pdf
PDF
C programming & data structure [arrays & pointers]
PDF
Simple C programs
PDF
8 arrays and pointers
PDF
PDF
Problem DefinitionBuild a Date class and a main function to test i.pdf
PPT
Unit4
PPT
C Language Unit-4
DOCX
PDF
PPS SSSSHHEHESHSHEHHEHAKAKHEHE12131415.pdf
PDF
CBSE Question Paper Computer Science with C++ 2011
DOCX
computer science and engineering data science
DOC
Pads lab manual final
PDF
ANSI C REFERENCE CARD
PDF
Spl book salution
PDF
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
C- Programming Assignment practice set 2 solutions
DSC Lab Manual fffffffffffffffffffff.pdf
C programming & data structure [arrays & pointers]
Simple C programs
8 arrays and pointers
Problem DefinitionBuild a Date class and a main function to test i.pdf
Unit4
C Language Unit-4
PPS SSSSHHEHESHSHEHHEHAKAKHEHE12131415.pdf
CBSE Question Paper Computer Science with C++ 2011
computer science and engineering data science
Pads lab manual final
ANSI C REFERENCE CARD
Spl book salution
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad

More from Malikireddy Bramhananda Reddy (17)

DOCX
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
PDF
C SLIDES PREPARED BY M V B REDDY
DOC
C AND DATASTRUCTURES PREPARED BY M V B REDDY
DOCX
DOC
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order

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.