Ramanathan

Digitally signed by Ramanathan
DN: cn=Ramanathan, c=IN, o=Commercial Taxed Dept
Staff Training Institute,, ou=Computer Lecturer,,
email=ctdsti@gmail.com
Location: Commercial Taxes Staff Training Institute,
Computer Lecturer,Ph:9442282076
Date: 2008.03.13 11:55:56 +05'30'

ð£ì‹ 1
C++ ªñ£NJ¡õN ªð£¼œ«ï£‚° Góô£‚è‚
輈¶¼‚èœ
(Object Oriented Concepts using C++)
1.1 ªð£¼œ«ï£‚° Góô£‚è ªñ£N
(Object Oriented Programming Language)

ðôîóŠð†ì C‚è™èÀ‚°ˆ b˜¾è£μ‹ å¼ è¼Mò£è‚
èEŠªð£P M÷ƒ°Aø¶. C‚è™èÀ‚è£ù b˜¾èœ èEŠªð£P Gó™
è÷£è¾‹ (Programs) ðò¡ð£†´ ªñ¡ªð£¼œè÷£è¾‹ (Application
Software) ïñ‚°‚ A¬ì‚A¡øù. Þˆî¬èò Gó™èÀ‹ ªñ¡ªð£¼†
èÀ‹ ã«î‹ å¼ Góô£‚è ªñ£NJ™ â¿îŠð´A¡øù.
å¼ èEŠªð£P Góô£ù¶, àœkì£èˆ îóŠð´‹ îó¾‚ ÃÁèO¡
e¶ ªêò™ð´A¡ø¶. Þ‰î àœk†´ˆ îó¾èœ ïñ‚°ˆ «î¬õò£ù
îèõ™ ÃÁè÷£è ñ£ŸøŠð†´, èEŠªð£P GóL¡ ªõOfì£èŠ ªðøŠ
ð´A¡øù.
ªî£ì‚è è£ô Góô£‚è ªñ£NèO™ àœk†´ ªõOf†´ˆ îó¾‚
ÃÁèœ ñ£Pè÷£è‚ (Variables) ¬èò£÷Šð†ìù. àœk†´ˆ îó¾‚
ÃÁèœ îó¾ Þùƒè÷£è (Data Types) õ¬èŠð´ˆîŠð†ìù. îó¾‚ ÃÁ
èO¡ e¶ G蛈îŠðì«õ‡®ò ªêò™ð£´è¬÷ èEŠªð£P‚°
ÜP¾Áˆî 膴Šð£†´‚ ßÁèœ (Control Statements) ðò¡ð†ìù.
Góô£‚è ªñ£Nèœ «õªø£¼ õ¬èJ½‹ ðò¡ð´A¡øù. å¼
C‚èL¡ b˜¾ðŸPò ïñ¶ 輈¶è¬÷ 弃è¬ñ‚è ܬõ àî¾A¡øù.
b˜‚èŠðì «õ‡®ò C‚è™èÀ‹ à¼õ£‚èŠðì «õ‡®ò ðò¡ð£†´
ªñ¡ªð£¼œèÀ‹ I辋 C‚èô£AŠ «ð£°‹«ð£¶, Góô£‚è ªñ£N
èO¡ Þ‰îŠ ð‡¹‚ÃÁ ÜFè º‚Aòˆ¶õ‹ ªðÁA¡ø¶. Þˆî¬èò
ªêò™Fø¡ ªè£‡ì Góô£‚è ªñ£Nèœ ðô à¼õ£‚èŠð†´œ÷ù.
Þ¬õ èEŠªð£P‚° ÜP¾Áˆ¶õîŸè£ù âOò õNº¬øè¬÷‚
ªè£‡´œ÷ù.
Þ¼ŠH‹, å¼ C‚轂è£ù b˜M¬ù, îó¾ (data), ªêò™ð£´èœ
(operations) âù Þ¼Ãø£èŠ HKˆ¶ «ï£‚°õ¶, ñQî˜èœ ï¬ìº¬ø
õ£›‚¬èJ¡ C‚è™èÀ‚° b˜¾è£μ‹ º¬ø«ò£´ åˆF¼‚èM™¬ô
â¡ð¶ àíóŠð†ì¶.
C++ «ð£¡ø ªð£¼œ«ï£‚° Góô£‚è ªñ£Nèœ,
ï¬ìº¬ø
õ£›‚¬èJ¡ C‚èô£ù Hó„C¬ùè¬÷ˆ b˜‚è, ªð£¶õ£è ñQî˜èœ
1

¬èò£À‹ º¬øè¬÷ Ü®Šð¬ìò£è‚ ªè£‡´
õ®õ¬ñ‚èŠ
ð†´œ÷ù. ªð£¶õ£è, ñQî˜èœ ï¬ìº¬øŠ Hó„C¬ùè¬÷ˆ
b˜Šð º¡, b˜¾‚° «î¬õŠð´‹ ð™«õÁ îQˆî ªð£¼œè¬÷
ܬìò£÷‹ 裇A¡øù˜. Üî¡H¡ ÜŠªð£¼œèÀ‚° Þ¬ì«òò£ù
àø¾º¬øè¬÷ à혉¶ ªè£œA¡øù˜. àø¾º¬ø â¡ð¶ ‘Þ¶
Þî¡ å¼ ð°F’ Ü™ô¶ ‘Þ¶ Þ‰î Þùˆ¬î„ ꣘‰î¶’ â¡ð¬î‚
°PŠð‹. ‘å¼ ªð£¼÷£ù¶ «õªø£¼ ªðKò ªð£¼O¡ å¼ ð°F’
â¡ð¬î»‹ ‘å¼ ªð£¼÷£ù¶ Þ¡ªù£¼ ªð£¼O¡ Þùˆ¬î„ ꣘‰î¶’
â¡ð¬î»‹ ¹K‰¶ ªè£œA¡ø ê£î£óíˆ Fø‹ð£´è«÷ ï¬ìº¬ø
õ£›‚¬èJ¡ C‚è™èÀ‚°ˆ b˜¾ 裇ðF™ Iè Þ¡Pò¬ñò£î
Þì‹ õA‚A¡øù. îó¾è¬÷»‹ ܈îó¾èO¡e¶ G蛈îŠð´‹ ªêò™
ð£´è¬÷»‹ 弃° «ê˜ˆ¶, C‚è™èÀ‚°ˆ b˜¾è£μ‹ Þ‰î õN
º¬ø¬òŠ ªð£¼œ«ï£‚° Góô£‚è‹ õöƒA»œ÷¶.
«õÁ ªê£ŸèO™ ÃÁõªîQ™, îó¾‚ ÃÁèO¡ ªî£°F, «õÁ
Hø ªêòŸÃÁè¬÷ ܬö‚è£ñ«ô, ªêò™ð£´è¬÷ G蛈¶õèŸø
CÁ °¿‚è÷£èŠ HK‚èŠð´Aø¶. Þˆî¬èò î󾂰¿ ÜîŸè£ù
ªêò™ð£´èÀì¡ «ê˜ˆ¶ ÞùŠªð£¼œ - ²¼‚èñ£è - ªð£¼œ (object)
âùŠð´Aø¶. ªêò™ð£´èœ, ªð£¼O¡ ð‡Hò™¬ð à혈¶A¡øù.
ï승ôèŠ ªð£¼¬÷‚ èEŠªð£P GóL™ ⴈõ Þ‰îŠ
ªð£¼œ 輈¶¼ àî¾Aø¶.
â´ˆ¶‚裆ì£è, å¼ èEŠH¬ò (Calculator) «ï£‚°ƒèœ. Ü
G¬ô (State), ð‡Hò™¹ (Behaviour) ÝAò¬õ àœ÷ù. G¬ô â¡ð¶,
c÷ Üèô‹, ªð£ˆî£¡èœ, 裆CˆF¬ó, ªêòŸ°Pèœ «ð£¡ø Üî¡
¹øˆ«î£Ÿøˆ¬î‚ °P‚A¡ø¶. ð‡Hò™¹ â¡ð¶, Æì™, èNˆî™,
G¬ùõèˆF™ «êIˆî™, G¬ùõ般î ÜNˆî™ «ð£¡ø Üî¡
ªêò™ð£´è¬÷ à혈¶A¡ø¶.
ªêò™ð£´èœ

îó¾è¬÷
FàœO´õîŸè£ù
ªð£ˆî£¡èœ
Fªêò™ð£´èœ, îó¾èœ,

M¬ìè¬÷‚ 裆´‹
裆Cˆ F¬ó

ðì‹ 1.1 Ü®Šð¬ì‚ èEŠH

2

ªð£¼œ«ï£‚° Góô£‚è ªñ£NJ™ å¼ èEŠH â¡ð¶ Þšõ£Á
«ï£‚èŠð´Aø¶:
ªð£¼œ - èEŠH
îó¾èœ:
Number1,result, operator, Number_backup

ªêò™ÃÁèœ:
Additon()
Subtraction()
Erase_Memory()
Display_Result() 

ªð£¼œ â¡ð¶ ªî£ì˜¹¬ìò ªêòŸÃÁèœ, Ü„ªêòŸÃÁ
èÀ‚è£ù îó¾èœ ÝAòõŸ¬ø‚ ªè£‡ì å¼ °¿õ£°‹. 
ªð£¼œ â¡ð¶, °PŠH†ì ªêòŸðóŠ¹ì¡ îò, îŸê£˜¹
ªè£‡ì å¼õ¬èˆ ¶¬í Gó™ Ý°‹.
îó¾è¬÷»‹ ܬõ ªî£ì˜ð£ù ªêòŸÃÁè¬÷»‹ ªð£¼œèœ
âùŠð´‹ Üô°è÷£è‚ °¿õ£‚°‹ ªêòô£‚è‹ à¬øªð£Fò£‚è‹
(Encapsulation ) â¡Â‹ 輈¶¼¾‚° õN õ°‚Aø¶.
îó¾è¬÷»‹ ªêòŸÃÁè¬÷»‹ å¼ ªð£¼œ õ¬óò¬ø‚°œ
å¡ø£èŠ H¬íˆ¶¬õ‚°‹ ªêò™¸†ð‹ à¬øªð£Fò£‚è‹
âùŠð´Aø¶.
å¼ õƒA‚ èí‚°, ñ£íõ˜, ðø¬õ, 裘, è£L «ð£¡ø¬õ
G¬ô ñŸÁ‹ ð‡Hò™¹ ÝAòõŸ¬ø 弃«è ªðŸÁœ÷ù â¡ð¬î
âOî£è‚ è£íº®»‹. ï¬ìº¬ø õ£›M™ è£íŠð´‹ à‡¬ñò£ù
ªð£¼œè«÷£´ àœ÷ åŸÁ¬ñ«ò èEŠªð£P GóL¡ ªð£¼œèÀ‚°
ÜõŸP¡ ê‚F¬ò»‹ ðò¡ð£†¬ì»‹ õöƒ°A¡ø¶. ªñ¡ªð£¼œ
Gó™èO™ à‡¬ñŠ ªð£¼œè¬÷ à¼õA‚°‹ ðE¬ò ªð£¼œèœ
(Objects) âO¬ñŠð´ˆF»œ÷ù.

3

â´ˆ¶‚裆´Š ªð£¼œèœ -

õƒA‚ èí‚°‹ ñ£íõ¼‹

õƒA‚ èí‚°
îó¾èœ:

Account number – long int
Name – char[15]
Opening balance –float;
Account type – char

ªêòŸÃÁèœ:
Accept_Details()
Display_Details()
Update_opening_balance()
Withdrawls()
Deposit()

ñ£íõ¡
îó¾èœ:

Date_of_birth – char[10]
Name – char[15];
Class, sec char[4];
Marks float

ªêòŸÃÁèœ:
Accept_Details()
Display_Details()
Total()
Average()
Grading()

1.2 𙽼õ£‚è‹ (Polymorphism)
ªêšõè‹, ê¶ó‹, õ†ì‹, õ¬÷«è£´ «ð£¡ø ð™«õÁ õ®õƒè¬÷
õ¬ó»‹ ðE¬ò â´ˆ¶‚ ªè£œ«õ£‹. ªõš«õÁ õ®õƒè¬÷ õ¬óò
ªõš«õÁ ªêòŸÃÁè¬÷ õ¬óòÁ‚è «õ‡®J¼‚°‹. ܈î¬èò
õ¬óò¬øèœ Þšõ£Á Þ¼‚èô£‹:
Draw_Square()
Read side
Drawrequired
lines

Draw_Circle()
Read radius

Draw_Rectangle()
Read length,
breadth Draw
required lines

Draw

Draw_Arc()
Read Start_angle,
End_angle,radius
draw

W«ö»œ÷ ªêòŸÃÁè¬÷ «ï£‚°è:
Draw (side) - å¼ ê¶ó‹ õ¬óõ
Draw (length, breadth) - å¼ ªêšõè‹ õ¬óõ
Draw (radius) - å¼ õ†ì‹ õ¬óõ
Draw(radius, start_angle, end_angle) - å¼ õ¬÷«è£´ õ¬óõ
Draw( ) â¡Â‹ ªêòŸÃÁ «õÁð†ì àœk´è¬÷ ãŸAø¶. «õÁð†ì
ªêò™ð£†¬ì‚ ªè£‡´œ÷¶. ðòù¬óŠ ªð£Áˆîõ¬óJ™ «õÁð†ì
õ®õƒè¬÷ õ¬óõ «õÁð†ì àœk´èÀì¡ Draw() ªêòŸ
ÃP¬ùŠ ðò¡ð´ˆ¶õ£˜. Draw( ) ªêòŸÃÁ «õÁð†ì àœk´èO¡
Ü®Šð¬ìJ™ «õÁð†ì º¬øèO™ ªêò™ð´‹ ñ«ò 𙽼õ£‚è‹
(Polymorphism) âùŠð´Aø¶.
«õÁð†ì ªêŒFèÀ‚° ñ£Áð†´„ ªêò™ð´‹ å¼ ªð£¼O¡
Fø«ù 𙽼õ£‚è‹ â¡ø¬ö‚èŠð´Aø¶.

4

Ü®Šð¬ì 5 . 𣽣†®èœ. ܬùˆ¶ Môƒ°èÀ‹ ªð£¶õ£ù ï숬î¬ò»‹ ªð£¶õ£ù ð‡¹‚ÃÁè¬÷»‹ ªè£‡´œ÷ù.3 ñó¹Kñ‹ (Inheritance) Þù‚°¿ (Class) â¡Â‹ îóMù‹ ï승ôA™ Gô¾‹ å¼ ªð£¼¬÷ à¼õA‚Aø¶. Mammals Young_ones Mammary_glands Functions: Parenting(). Ì„Cèœ. Skeleton_hollow. àí¾ ÝAòõŸ¬ø Môƒ°èO¡ Þò™¹èœ Ü™ô¶ ð‡¹‚ÃÁèœ â¡A«ø£‹. è‡èœ. skin. Môƒ°èO¡ åš«õ£˜ à†°¿¾‹ ªð£¶õ£ù ï숬î¬ò»‹.1. ðø¬õèœ âùŠ ðôõ£ø£èŠ HK‚è º®»‹ â¡ð¬î ï£ñP«õ£‹. food Functions : Reproduction() living_style() prey_Style() Birds: Young_ones. Þù‚°¿ â¡ð¶ ªð£¶õ£ù ð‡Hò™¹ ªè£‡ì ༠ªð£¼œèO¡ õ£˜Š¹¼ (Template) Ý°‹. Gô‹-c˜ õ£›õù. àJKùƒèO¡ °¿¬õ MôƒAù‹ â¡A«ø£‹. Üî£õ¶. ÞùŠªð¼‚è‹. Þò™¬ð»‹ ªè£‡®¼‚°‹. á˜õù. õ£¿‹º¬ø. â´ˆ¶‚裆ì£è. habitat. Þî¬ùŠ ðìñ£è Þšõ£Á à¼õA‚èô£‹: Class animal : Features : eyes. Môƒ°è¬÷ æ˜ Þù‚ °¿õ£è õ¬èŠð´ˆ¶A«ø£‹. Feeding_Style. Reproduction_style() ðì‹ 1. Þ¬óªè£œÀ‹ º¬ø «ð£¡ ø¬õ Môƒ°èO¡ ï숬î âù‚ ªè£œ÷ô£‹. Functions: Migration(). «î£™. î¼M‚èŠð†ì Þù‚°¿‚èœ ê‚F I‚è¬õ. õ£Nì‹. è£óí‹ Ü¬õ îñ‚°Kò îQˆî Þò™¹è«÷£´ Ü®Šð¬ì Þù‚ °¿M¡ ªêòô£Ÿø™è¬÷»‹ î‹ñèˆ«î ªè£‡´œ÷ù. Môƒ°è¬÷Š 𣽣†®èœ. ðø¬õèœ ÝAò à†°¿‚èœ. 𣽣†®èœ. Môƒ° â¡Â‹ ‚°¿M¡ ð‡¹ è¬÷Š ðA˜‰¶ ªè£œA¡øù. Ì„Cèœ. á˜õù.1 ñó¹Kñ‹ Môƒ° â¡ð¶ Ü®Šð¬ì Þù‚°¿ (base class) âùŠð´Aø¶. ðø¬õèœ â¡ð¬õ î¼M‚èŠð†ì Þù‚°¿‚èœ (derived classes) âùŠð´A¡øù. Gô‹-c˜ õ£›õù. Ü«î «õ¬÷J™ îˆîñ‚«è àKò îQˆî Þò™¹è¬÷»‹ ð£Eè¬÷»‹ ªè£‡´œ÷ù.

㟪èù«õ ðò¡ð£†®™ àœ÷ ªñ¡ªð£¼O™. Þˆî¬èò îó¾ ñ¬øŠ¹ (Data Hiding) Ü™ô¶ îó¾ ܼõñ£‚è‹ (Data Abstraction) îó¾èÀ‚°Š ð£¶è£Š¬ð ï™°Aø¶. Þî«ù£´ ªî£ì˜¹¬ìò ªêòŸÃÁèœ. 嚪õ£¼ FøŠH¬ò»‹ å¼ ªð£¼÷£è «ï£‚èô£‹. è†ììˆF½œ÷ 嚪õ£¼ c˜ ªõO«òŸPèO™ ªõO«òÁ‹ cK¡ Ü÷¬õ»‹. Þî¡ Íô‹ °Pº¬ø ñÁðòù£‚è‹ (Code Resuability) ꣈Fòñ£Aø¶. ¹¶ŠH‚èŠð†ì ÃÁè¬÷ ެ툶 «î£Á‹ ñ£P‚ ªè£‡®¼‚°‹ àôA¡ «î¬õè¬÷ âF˜ªè£œ÷ õN õ°‚Aø¶. 㟪èù«õ Þ¼‚°‹ æ˜ Þù‚°¿M¡ Ü®Šð¬ìJ™ «õ«ø£˜ Þù‚°¿¬õˆ î¼Mˆ¶‚ ªè£œ÷ õNõ°‚Aø¶.  ñó¹Kñ‹ (Inheritance). Þ‰î Gó¬ô ⿶õˆ «î¬õò£ù Mõóƒèœ: Ü‰î‚ è†ììˆF™ GÁõŠð†´œ÷ c˜ˆ FøŠHèO¡ (Taps) â‡E‚¬è. ÞÁFò£è ªñ£ˆî cK¡ ¸è˜õ÷¾.  å¼ ªêòŸÃÁ (Function) Ü™ô¶ ªêòŸ°P‚° (Operator) ðô õ¬óò¬øè¬÷„ ꣈Fòñ£‚°î™ Íô‹ 𙽼õ£‚è‹ (Polymorphism) ªñ¡ªð£¼œ C‚èŸð£†®¬ù (Complexity) °¬ø‚Aø¶. 冴ªñ£ˆî cK¡ ¸è˜¬õ»‹ èí‚ A´õ«î Þ‰î GóL¡ «ï£‚è‹.  ªî£ì˜H™ô£î ªõO„ ªêòŸÃÁèœ (Þù‚°¿¾‚° ªõO«ò õ¬óòÁ‚èŠð†´œ÷ ªêòŸÃÁèœ) Þù‚°¿¾‚°œ Þ¼‚°‹ îó¾è¬÷ Üμè º®ò£¶. 1. 嚪õ£¼ FøŠHJ¡ õNò£è¾‹ ªõO«òÁ‹ cK¡ Ü÷¾.4 å¼ ï¬ìº¬ø â´ˆ¶‚裆´: i†´¢ c˜Šðò¡ð£´ i†´‚° c˜õöƒ°‹ ܬñŠ¬ðªò£ˆ¶ å¼ Gó¬ô à¼õ£‚° õî£è‚ ªè£œ«õ£‹. Gó™ °Pº¬øJ¡ ñÁðòù£‚般 (Code Reusability) ꣈Fòñ£‚A»œ÷¶. c˜Š 6 . îó¾è¬÷ Üμèˆ î¬ì ªêŒõ¶ì¡ å¼ ªð£¼O¡ I舫î¬õò£ù Þò™¹è¬÷ ñ†´«ñ ªõO‚ 裆´Aø¶.Þù‚°¿M¡ ð‡¹è¬÷ ߆®‚ ªè£œÀ‹ î¬è¬ñ ñó¹Kñ‹ (Inheritance) â¡ø¬ö‚èŠð´Aø¶. ªð£¼œ«ï£‚° Góô£‚èˆF¡ ðô¡èœ:  Gó™èO™. ñó¹Kñ‹ â¡ð¶ î¼M‚èŠð†ì Þù‚°¿M¡ ªêòô£Ÿø¬ô I°M‚Aø¶. îó¾èœ ñŸÁ‹ ªêòŸÃÁè¬÷ å¡Á«ê˜ˆ¶Š ªð£¼œ è÷£è 弃è¬ñ‚è Þù‚°¿ (Class) â¡Â‹ îóMù‹ ðò¡ ð´Aø¶.

ܶ 嚪õ£¼ °ö£Œ ñŸÁ‹ ÜF™ Þ¬í‚èŠð†´œ÷ FøŠHèO¡ ð£¬îò G¬ô â¡ù âù‚ «è†ìP‰¶ ªê£™½‹.3 FøŠH â¡Â‹ ªð£¼œ cK¡ ðò¡ð£†¬ì à¼õA‚°‹ Gó™. âšõ÷¾ c˜ ¸èóŠ ð†´œ÷¶ âù‚ è†ììŠ ªð£¼¬÷‚ «è†«ì£‹ âQ™. FøŠH Fø‰¶œ÷î£. Þ‰îˆ F†ìŠðE¬ò ðì‹ 1. ܬùˆ¶ c˜‚°ö£Œè¬÷»‹ FøŠHè¬÷»‹ 弃A¬í‚°‹ è†ìì‹ (Building) â¡Â‹ ªð£¼À‹ Þ¼‚èô£‹. FøŠH â¡Â‹ ªð£¼¬÷ Þšõ£Á à¼õA‚èô£‹: îó¾: Tap_open. 7 . Þ‰îŠ ðEè¬÷„ ªêŒõˆ FøŠH â¡Â‹ ªð£¼œ.ðì‹ 1. Qty_water. ðò¡ ð´ˆîŠð†ì cK¡ Ü÷¬õ‚ °P‚辋. Water_source ªêòŸÃÁèœ: Start() Stop() ðì‹ 1.2 i†´ c˜Šðò¡ð£´ 𣌬õ ªî£ìƒ°õ¶/ GÁˆ¶õ¶ ñŸÁ‹ °PŠH†ì è£ô Ü÷M™ ¸èóŠ 0ð´‹¢ cK¡ Ü÷¬õˆ î¼A¡øî£è¾‹ ޡ‹ ÞõŸ¬ø åˆîî£è¾‹ Þ¼‚°‹. FøŠHèÀ‚° c¬ó MQ«ò£‚A‚°‹ c˜‚°ö£Œ (Water pipe) â¡Â‹ ªð£¼¬÷»‹ ªè£‡® ¼‚°‹. Í®»œ÷î£ â¡ð¬î‚ è‡è£E‚辋.4 -™ àœ÷õ£Á à¼õA‚èô£‹. c˜ âƒA¼‰¶ õ¼Aø¶ â¡ð¬î ÜPò¾ñ£ù ꣡Á¼ ñ£Pè¬÷‚ (Instance Variables) ªè£‡®¼‚è «õ‡´‹.

îó¾è¬÷ àœk´è÷£è ÜŠHˆ îñ‚°œ«÷ îèõ™ ðKñ£Ÿø‹ ªêŒ¶ªè£œA¡øù. t1.water_consumed(). 8 . ÞÁF M¬ì¬ò‚ èí‚Aì 塬øªò£¡Á ܬö‚°‹ ªð£¼œè¬÷‚ ªè£‡ì àœ÷¶. «ñô£÷˜èœ.water_consumed+t3.water_consumed()+t2. îQˆîQ FøŠHJL¼‰¶ ¸èóŠð†ì cK¡ Ü÷¾ t1.4 å¼i†®™ c˜õöƒ° º¬ø¬ñ ªêòŸÃÁèœ: Water_flow() Valve_Status() Time_Taken() ¸èóŠð†ì ªñ£ˆî cK¡ Ü÷¾ total_amount â¡Â‹ ñFŠ¹. ܬùˆ¶ Gó™ ÃÁèO¡ 弃A¬í‰î ªêò™ð£´.. è£óí‹ t1 â¡Â‹ FøŠH ¸è¼‹ cK¡ Ü÷¾ P1 â¡Â‹ °ö£Jù£™ b˜ñ£Q‚èŠð´Aø¶. t2.water_consumed() â¡Á èí‚AìŠð´‹. Length. õƒA‚ èí‚° èœ Þ¡Â‹ Þ¶«ð£¡Á ï승ôA™ è£μ‹ ªð£¼œèœ â´ˆî£÷Š ð´A¡øù.water_consumed() â¡Â‹ ªêòŸÃÁ ܬöŠ¹ P1 â¡Â‹ °ö£ŒŠ ªð£¼Àì¡ ªî£ì˜¹ªè£‡´ Ü‰î‚ °ö£Œ õN«ò 𣌉î cK¡ Ü÷¬õ‚ «è†ìP»‹. t2.å¼ i†®¡ ñ£FK c˜ õöƒ° º¬ø¬ò‚ 裆´‹ ðì‹ t1. GóL¡ ÞÁF M¬ì¬ò õöƒ°A¡ø¶. p2. â¡Á ÜPòŠð´‹. Þšõ£Á å¼ Góô£ù¶.. Iè Þò™ð£ù º¬øJ™ ï승ôèŠ ªð£¼œèœ. p3 ÝAò¬õ c˜‚ °ö£ŒŠ ªð£¼œèœ ªð£¼œ:water_pipe îó¾: Thickness.water_consumed(). Þ¡¬øò Góô£‚èˆF™ ñ£íõ˜èœ. Þšõ£Á å¼ ªð£¼O¡ ð‡Hò™¬ð„ ªêòŸÃÁè÷£èŠ ð£M‚°‹ 輈«î£†ì«ñ ªð£¼œ«ï£‚° Góô£‚èˆF¡ °PŠH†´„ ªê£™ô «õ‡®ò CøŠ¹‚ Ãø£°‹. Gó™èO™ ¬èò£÷Šð´‹ ªð£¼œèO™ M÷‚è‹ ªðÁA¡øù. Valves ðì‹ 1. 嚪õ£¼ ªð£¼À‹ îˆî‹ ðƒèOŠ¬ð ï™° A¡øù.. ªð£¼œèœ. t1.. t3 ÝAò¬õ FøŠHŠ ªð£¼œèœ p1.

ªð£¼œ â¡ðî¡ à†è¼ˆ¶ â¡ù? 2. II. W›‚è£μ‹ Mù£‚èÀ‚°„ ²¼‚èñ£è M¬ì ÜO‚辋: 1. 𙽼õ£‚è‹ â¡ð¶ ñó¹KñˆFL¼‰¶ âšõ£Á «õÁð´Aø¶? III.height. «è£®†ì Þ숬î GóŠ¹è Ü) ï승ôèŠ ªð£¼œè¬÷‚ èEŠªð£P GóL™ â´ˆî£÷ ________ 輈¶¼ àî¾Aø¶. ܉GÁõù‹ îù¶ ðEò£÷˜èœ ܬùõK¡ îèõ¬ô»‹ «êIˆ¶ ¬õˆ¶œ÷¶. ailments. date of birth. paper presentations Þ) Technician . language. Ý) îó¾è¬÷»‹ ÜõŸ¬ø‚ ¬èò£À‹ ªêòŸÃÁè¬÷»‹ å¡ø£èŠ H¬íˆ¶¬õ‚°‹ ªêò™¸†ð‹ ____________________ â¡ø¬ö‚èŠð´Aø¶. ðEò£÷˜èO¡ ðEŠªð£ÁŠ¹ Ü®Šð¬ìJ™ «êIˆ¶ ¬õ‚èŠð†´œ÷ Ã´î™ Mõóƒèœ: Ü) Stores .ðJŸC Mù£‚èœ I. department. salary Ý) Scientist .date of joining. wages 9 . risk factor.area of specialisation. à¬øªð£Fò£‚è‹ â¡ð¶ â¡ù? 3. dept. current project details. Þ) «õÁð†ì ªêŒFèÀ‚° ñ£Áð†´„ ªêò™ð´‹ å¼ ªð£¼O¡ Fø«ù____________________________ â¡ø¬ö‚èŠð´Aø¶ ß) 㟪èù«õ Þ¼‚°‹ îóMùˆ¬î Ü®Šð¬ìò£è‚ ªè£‡´ ¹Fò îóMùƒè¬÷ à¼õ£‚°‹ ªêò™¸†ð‹___________________ â¡ø¬ö‚èŠð´Aø¶. ðEò£÷˜èO¡ ªð£¶õ£ù Mõóƒèœ: Name. weight. W›‚è£μ‹ F†ìŠðE‚è£ù îóMùƒè¬÷ õ®õ¬ñ‚辋 å¼ GÁõù‹ î¡Â¬ìò ïìõ®‚¬èèÀ‚è£è å¼ îó¾ ñ£FKòˆ¬î (Data Model) îò£K‚è M¼‹¹Aø¶. nativity.

A¬ìñ†ìˆ îˆî™.[. >. °P»¼ˆ ªî£°FJ™ W›‚è£μ‹ °P»¼‚èœ ÜìƒA»œ÷ù: A.1 M™¬ôèO¡ õ¬èŠð£´èœ GÁˆîŸ °Pèœ 2.9 +. ]. ?... C++ â¡Â‹ ªðò¬ó„ (C H÷v H÷v âù à„êK‚è «õ‡´‹) ņ®òõ˜ K‚ ñ£vC†® â¡ðõ˜ Ýõ£˜. &..Góô£‚è‚ °Pº¬ø‚°ˆ «î¬õò£ù àÁŠ¹èO¡ Ü®Šð¬ì õ¬èèœ) à¼õ£‚èŠ ð´A¡øù. ªê½ˆF F¼Šð™ ñŸÁ‹ Hø °P»¼‚èœ.. ou=Computer Lecturer.. \.. {.. ‘. -. ..Z. 10 ..Z.. *. Computer Lecturer.ªñ£N¬òŠ «ð£¡«ø C++ ªñ£N»‹ å¼ °P»¼ˆ ªî£°F¬ò‚ ªè£‡´œ÷¶. } =..1 º¡Â¬ó C++ ªñ£N 1980-èO¡ ªî£ì‚èˆF™ ã¯&¯ ªð™ ÝŒ¾‚ ÃìˆF™ «ü˜¡ v†ªó÷v†óŠ (Bjarne Stroustrup) Üõ˜è÷£™ à¼õ£‚èŠð†ì¶.2. M™¬ôèœ ðì‹ 2.. <.. “.1 CøŠ¹„ ªê£Ÿèœ å¼ èEŠªð£P ªñ£NJ¡ Gó™ªðò˜ŠH‚°Š (Language Compiler) ¹KA¡ø ªð£¼œªè£‡ì ªê£Ÿèœ CøŠ¹„ ªê£Ÿèœ âùŠð´A¡øù. .1-™ àœ÷õ£Á õ¬èŠð´ˆîŠð´A¡øù.. 2. ++ â¡ð¶ C ªñ£NJ¡ I°Š¹„ ªêòŸ°P Ý°‹. M™¬ôèœ CøŠ¹„ ªê£Ÿèœ °PŠªðò˜èœ ñ£PLèœ ªêòŸ°Pèœ ðì‹ 2. -.Ramanathan Digitally signed by Ramanathan DN: cn=Ramanathan. a... (... !. <=. c=IN.03. Ü®Šð¬ì Þùƒèœ ðŸP„ ²¼‚èñ£è‚ 裇«ð£‹....com Location: Commercial Taxes Staff Training Institute. : %. ). #. !=. 0. >=. M™¬ô â¡ð¶ å¼ GóL™ àœ÷ e„CÁ îQˆî Üô° Ý°‹.13 11:56:42 +05'30' ð£ì‹ 2 C++ ªñ£NJ¡ º¡«ù£†ì‹ (Overview of C++) 2.. @ ªõŸÁ ÞìªõO. email=ctdsti@gmail.Ph:9442282076 Date: 2008. ÜFL¼‰¶ M™¬ôèœ (Tokens. Ü®Šðð¬ì Þùƒèœ 冴ªñ£ˆîñ£è M™¬ôèœ (Tokens) âùŠð´A¡øù. /.. o=Commercial Taxed Dept Staff Training Institute..2 C++ °P»¼ˆ ªî£°F (C++ Character Set) C.

CøŠ¹Š ðò¡ð£†´‚ªèù 嶂èŠð†ì ªê£Ÿèœ Þ¬õ. Þ„ªê£Ÿè¬÷„
ê£î£óí °PŠªðò˜è÷£èŠ ðò¡ð´ˆî º®ò£¶. C++ ªñ£NJ™ ðò¡
ð´ˆîŠð´‹ CøŠ¹„ ªê£ŸèO¡ ð†®ò¬ô ܆ìõ¬í 2.1-™ 裇è.
auto

break

case

const

class

continue

default

delete

do

else

enum

for

friend

goto

if

inline

new

operator

private

protected

public

return

signed

sizeof

static

struct

switch

this

unsigned

virtual

while
܆ìõ¬í 2.1 CøŠ¹„ ªê£Ÿèœ

2.2.2 °PŠªðò˜èœ (Identifiers)
°PŠªðò˜èœ, ñ£Pèœ (Variables) â¡Á‹ ܬö‚èŠð´A¡øù.
ñ£Pèœ â¡ð¬õ, ñFŠ¹ Ü™ô¶ ñ£PLè¬÷ˆ A»œ÷ G¬ùõèŠ
ªð†®è¬÷‚ °P‚A¡øù. ñ£PJ¡ ªðò˜ æ˜ â¿ˆF™ Ü™ô¶
Ü®‚WP™(Underscore) ªî£ìƒA, Üî¬ùˆ ªî£ì˜‰¶ ⿈¶ Ü™ô¶
â‡è¬÷‚ ªè£‡®¼‚°‹. â´ˆ¶‚裆ì£è _test; test; sum12 ÝAò¬õ
ãŸèˆî° °PŠªðò˜è÷£°‹. îó¾ Þùƒè¬÷Š ðŸPŠ ð®ˆî Hø°
ñ£Pè¬÷Š ðŸP «ñ½‹ 𣘊«ð£‹.

2.2.3 ñ£PLèœ (Constants)
ñ£PL â¡ð¶ ñ£Ÿø º®ò£î ñFŠ¬ð‚ ªè£‡ì å¼ îó¾ Mõó‹
Ý°‹. ñ£PL â¡ð¶ â‡õ¬è¬ò„ «ê˜‰îî£è«õ£, ⇠ܙô£î
õ¬è¬ò„ ꣘‰îî£è«õ£ Þ¼‚èô£‹. â‡õ¬è ñ£PL â‡
ñFŠ¹è¬÷«ò ªè£‡®¼‚°‹. º¿ â‡í£è Þ¼‚èô£‹. ðF¡ñŠ
¹œO â‡í£è¾‹ (decimal numbers) Þ¼‚èô£‹. º¿â‡èœ (Integers)
ñŸÁ‹ IŠ ¹œO (floating point) â‡èœ â‡õ¬è ñ£PLèœ Ý°‹.

2.2.4 º¿â‡ ñ£PL (Integer Constant)
º¿â‡ ñ£PL â¡ð¶ °¬ø‰î¶ æ˜ Þô‚般îò£õ¶
ªè£‡®¼‚è «õ‡´‹. H¡ùŠð°F ⶾ‹ Þ¼‚è‚Ã죶.
• + Ü™ô¶ - â¡Aø º¡ªù£†´‚ °P (prefix) Þ¼‚èô£‹.
• 0 - M™ ªî£ìƒ°‹ â‡èœ â‡ñ (Octal) ñ£PLè÷£è‚
è¼îŠð´‹. (â-´) 010 = 8 ([8]10 = [10]8).
• 0X âùˆ ªî£ìƒ°‹ â‡èœ ðFùÁñ (hexadecimal) â‡è÷£è‚
è¼îŠð´‹. (â-´) 0XF=15 ([15]10 = [F]16).
11

2.2.5 IŠ ¹œO ñ£PL (Floating Point Constant)
IŠ ¹œO ñ£PL â¡ð¶ °PJ†ì ªñŒ â‡¬í‚ °P‚°‹.
ܶ, º¿â‡ ð°F, ðF¡ñŠ ¹œO, H¡ùŠ ð°F, Ü´‚ªè‡ ð°F
ÝAò ° ð°Fè¬÷‚ ªè£‡®¼‚°‹. å¼ IŠ ¹œO â‡
ñ£PL¬ò‚ °PŠH´‹«ð£¶ º¿â‡ ð°F, H¡ùŠ ð°F ÝAò
Þ󇮙 塬ø M†´Mìô£‹. Ýù£™ Þó‡´‹ Þ™ô£ñ™ Þ¼‚è
º®ò£¶. â´ˆ¶‚裆ì£è 58.64 â¡ð¶ ãŸèˆî° IŠ ¹œO â‡
(ªñŒªò‡) Ý°‹. Þ‰î ⇬í Ü´‚ªè‡ º¬øJ™
W›‚è£μñ£Á °PŠHìô£‹:


5.864E1 => 5.864*101 => 58.64
5.864E-2 => 5864*10-2 => 58.64
0.5864E2 => 0.5864*102 => 58.64

IŠ ¹œO â‡è¬÷ Ü´‚ªè‡ º¬øJ™ °PŠH´‹«ð£¶ E
Ü™ô¶ e â¡Â‹ ⿈¬îŠ ðò¡ð´ˆî «õ‡´‹.

2.2.6 °P»¼ ñ£PL (Character Constant)
°P»¼ ñ£PL â¡ð¶ 埬ø «ñŸ«è£œ °PèÀ‚°œ îóŠð´‹
埬ø‚ °P»¼¬õ‚ ªè£‡®¼‚°‹. C++ ªñ£NJ¡ °P»¼ˆ
ªî£°FJ™ õ¬óòÁ‚èŠð†´œ÷ù â‰î‚ °P»¼õ£è¾‹ (ASCII
ªî£°FJ¡ ܃èñ£ù â‡èœ èEî/åŠd†´/Hø CøŠ¹‚
°P»¼õ£è¾‹) Þ¼‚èô£‹. îˆî™ (tab), H¡QìªõO (backspace)
õK„ªê½ˆF (line feed), ñFŠHL (null), H¡ê£Œ¾ (backslash) ÝAò Cô
°P»¼‚èœ M´ð´ õK¬êò£è (escape sequence) °PŠHìŠð´A¡øù.
M´ð´ õK¬êèœ H¡ê£Œ¾‚ «è£†¬ì º¡ªù£†ì£è‚ ªè£‡´ 埬ø
⿈ °PŠHìŠð´‹. ܆ìõ¬í 2.2-™ M´ð´ õK¬ê‚ °P»¼‚
è¬÷‚ 裇è.

12

M´ð´ õK¬ê

õ®õŸø °P»¼

\a

ñE åLŠ¹

\b

H¡QìªõO

\n

¹Fò õK/ õK„ªê½ˆF

\t

A¬ìñ†ìˆ îˆî™

\v

ªêƒ°ˆ¶ˆ îˆî™

\\

H¡ê£Œ¾‚ «è£´

\’ (Ü) \”

埬ø/Þó†¬ì «ñŸ«è£œ

\o

â‡ñ â‡

\X

ðFùÁñ â‡

\0

ñFŠHL
܆ìõ¬í 2.2. M´ð´ õK¬ê‚ °P»¼‚èœ

2.2.6 êó G¬ô»¼ (String Literal)
êó G¬ô»¼ â¡ð¶ Þó†¬ì «ñŸ«è£œ °PèÀ‚°œ îóŠð´‹
°P»¼‚èO¡ õK¬ê¬ò‚ ªè£‡®¼‚°‹. êó G¬ô»¼‚èœ
°P»¼‚èO¡ ÜEò£è‚ (array of characters) è¼îŠð´A¡øù. 嚪õ£¼
êó G¬ô»¼¾‹ î£ù¬ñõ£è (by default) ‘\0’ â¡Â‹ CøŠ¹‚ °P»¼¬õ
ߟP™ ެ툶‚ ªè£œÀ‹. Þ¶ êóˆF¡ ÞÁF¬ò‚ °P‚Aø¶.
(â-´) : “testing”

2.2.7 ªêòŸ°P (Operator)
ªêòŸ°P â¡ð¶ å¼ ñFŠ¬ð M¬ìò£èŠ ªðÁõ G蛈îŠðì
«õ‡®ò å¼ ªêò™ð£†¬ì‚ °P‚Aø¶. ªêòŸ°Pò£ù¶ ªêò«ôŸH
èO¡ (Operands) e¶ ªêò™ð´A¡ø¶.
â´ˆ¶‚裆´ :
RESULT = NUM1+ NUM2

ÞF™, NUM1, NUM2 ÝAò¬õ ªêò«ôŸHèœ. + â¡ð¶ Þó‡´ â‡
è¬÷‚ Æ® M¬ì Ã†ì™ ªêòŸ°P Ý°‹.
= â¡Â‹
ñFŠH¼ˆî™(assignment) ªêòŸ°PJ¡ àîM»ì¡ M¬ì ñFŠ¹,
RESULT â¡Â‹ ñ£PJ™ «êI‚èŠð´Aø¶. C++ ªñ£NJ™ ðò¡
ð´ˆîŠð´‹ ªêòŸ°PèO¡ ð†®ò¬ô ܆ìõ¬í 2.3-™ 裇è.

13

[]
()

*
+

%
<<

==
!=

=
*=

>=
&=

.

-

>>

^

/=

^=

->

~

<

|

+=

|=

++

!
size of

>
<=

&&
||

-=
%=

, -#

<<=

##

&

/

>=

?:

܆ìõ¬í 2.3 C++ ªñ£NJ¡ ªêòŸ°Pèœ

W›‚è£μ‹ ªêòŸ°Pèœ C++ ªñ£N‚«è àKˆî£ù¬õ:
:: .* ->*
# ñŸÁ‹ ## ÝAò ªêòŸ°Pèœ º¡ªêòLò£™ (Preprocessor)
ðò¡ð´ˆF‚ ªè£œ÷Šð´ð¬õ.
ªêòŸ°Pè¬÷ Þšõ£Á õ¬èŠð´ˆîô£‹:


èí‚W´ (Arithmatic)

ñFŠH¼ˆî™ (Assignment)

ªð£¼†ÃÁˆ ªîK¾ (Component Selection)

Gð‰î¬ù (Conditional)

î¼‚è‹ (Logical)

¬èò£À¬è (Manipulator)

àÁŠHù˜ °PŠ¹ Mô‚è‹ (Member dereferencing)

G¬ùõè «ñô£‡¬ñ (Memory Management)

º¡ªêòL (Preprocessor)

åŠd´ (Relational)

õ¬óªò™¬ô‚ ÃÁ𣴠(Scope Resolution)

ï蘾 (Shift)

Þùñ£Ÿø‹ (Type Cast)
Þ싪ðÁ‹ ªêò«õôŸHèO¡ â‡E‚¬è Ü®Šð¬ìJ™
ªêòŸ°Pè¬÷ å¼ñ‹ (Unary) Þ¼ñ‹ (Binary), º‹ñ‹ (Ternary) âù
Íõ¬èò£èŠ HK‚èô£‹.
â´ˆ¶‚裆´:
å¼ñ„ ªêòŸ°P‚° å¼ ªêò«ôŸH«ò «î¬õ.
Þ¼ñ„ ªêòŸ°P‚° Þ¼ ªêò«ôŸHèœ «î¬õ.
º‹ñ„ ªêòŸ°P‚° Í¡Á ªêò«ôŸHèœ «î¬õ.

14

-> :: M÷‚è‹ Þ¼ñ‚ Ã†ì™ Þ¼ñ‚ èNˆî™ ªð¼‚è™ õ°ˆî™ õ°eF Þì¶ ï蘾 õô¶ ï蘾 à‹ Ü™ô¶ îQˆî Ü™ô¶ è à‹ î¼‚è Ü™ô¶ ñFŠH¼ˆî™ õ°ˆ¶ ñFŠH¼ˆî™ Æ® ñFŠH¼ˆî™ ªð¼‚A ñFŠH¼ˆî™ õ°eF ñFŠH¼ˆî™ èNˆ¶ ñFŠH¼ˆî™ Þì‹ï蘉¶ ñFŠH¼ˆî™ õô‹ï蘉¶ ñFŠH¼ˆî™ H†G¬ô à‹ ñFŠH¼ˆî™ H†G¬ô Ü™ô¶ ñFŠH¼ˆî™ Mì„CP¶ M슪ðK¶ Mì„CP¶ Ü™ô¶ Gè˜ M슪ðK¶ Ü™ô¶ Gè˜ Gè˜ GèK™¬ô «ïó®Š ªð£¼†ÃÁ ªîK¾ ñ¬øºèŠªð£¼†ÃÁªîK¾ õ¬óªò™¬ô Üμè™/ ÃÁ𣆴„ ªêòŸ°P .õ¬è Ã†ì™ ªêòŸ °P M÷‚è‹ & ºèõK ²†ì™ ! è âF˜ñ¬ø * àœ«ï£‚è™ ++ I°Š¹ ~ H†G¬ô GóŠ¹ — °¬øŠ¹ - å¼ñ âF˜ñ‹ + å¼ñ «ï˜ñ‹ ðì‹ 2.* °PŠ¹ Mô‚°„ ªêòŸ°P Gð‰î¬ù -> * Þù‚°¿ àÁŠ¹‚è£ù °PŠ¹ Mô‚è‹ ?: º‹ñ„ ªêòŸ°P 裟¹œO .4(Ý) Þ¼ñ„ ªêòŸ°Pèœ 15 . ñFŠHì™ Ü†ìõ¬í 2.4(Ü) å¼ñ„ ªêòŸ°Pèœ ªêòŸ°P + ªð¼‚è™ * / % ï蘾 << >> H†G¬ô & | ^ î¼‚è‹ && || ñFŠH¼ˆî™ = /= += *= %= -= <<= >>= &= |= åŠd´ G蘊𣴠ªð£¼†ÃÁ ªîK¾ Þù‚°¿ àÁŠHù˜ < > <= >= == != .

/= %= ðò¡ð£´ Ã†ì™ èNˆî™ ªð¼‚è™ õ°ˆî™ º¿â‡ õ°eF èí‚A†´ ñFŠH¼ˆî™ èí‚W†´„ ªêòŸ°Pèœ. a = a-1â¡ð Gè˜) ++a. a = a-1 â¡ð Gè˜) a *= 2.1 èí‚W†´„ ªêòŸ°Pèœ (Arithmatic Operators) èí‚W†´„ ªêòŸ°Pèœ èEî„ ªêò™ð£´è¬÷ G¬ø«õŸøŠ ðò¡ð´ˆîŠð´A¡øù.= *=. Þˆî¬èò î¼‚è‚ °¿õ£‚è‹ ªî£ì˜¹Áˆî‹ (association) âùŠð´Aø¶.2. (a=a/5) a++.7. èí‚W†´‚ «è£¬õèœ (arithmatic expressions) ܬñ‚èŠð´A¡øù. â´ˆ¶‚裆´èœ: • • • • • • • • • • a = -5. (H¡ I°Š¹„ ªêòŸ°P. (º¡ I°Š¹„ ªêòŸ°P.-a. (a = b + xy ) ªêòŸ°Pèœ º¡ÂK¬ñJ¡ Ü®Šð¬ìJ™ G¬ø«õŸøŠð´A¡øù. a = a+1 â¡ð Gè˜) . ªêòŸ°PèÀ‹ °PŠH†ì î¼‚è º¬øŠð® °¿õ£‚èŠð†´ ñFŠHìŠð´A¡øù.6 -™ 裇è. a = a+1 â¡ð Gè˜) a. 16 . (H¡ °¬øŠ¹„ ªêòŸ°P. â‡õ¬è ñ£PLèœ/ñ£Pèœ.y).2. (a = a%5) a = b + pow(x. ªêò«ôŸHèÀ‹. èí‚W†´„ ªêòŸ°PèO¡ ð†®ò™ 裇è: ªêòŸ°P + * / % +=. èEî„ ªêòŸ°PèO¡ õ¬è ñŸÁ‹ ªî£ì˜¹Áˆîˆ¬î ܆ìõ¬í 2. (º¡ °¬øŠ¹„ ªêòŸ°P. F¬êºè‹ â¡Á‹ Ãøô£‹. . (a = a*2 ) a %= 5. a/=5. a = +b. èí‚W†´„ ªêòŸ°Pè÷£™ Þ¬í‚èŠð†ì ªêòŸÃÁ ܬöŠ¹ ÝAòõŸ¬ø àœ÷ì‚A.-.

/.— èEî‹-å¼ñ‹ ÞìI¼‰¶ õô‹ º¡ªù£†´ ++.6 èEî„ ªêòŸ°PèO¡ º¡ÂK¬ñ W›‚è£μ‹ â´ˆ¶‚裆´èœ. å¼ñ - èEî‹-å¼ñ‹ õôI¼‰¶ Þì‹ *.ªêòŸ°P º¡ÂK¬ñ õ¬è F¬êºè‹ ( ). 5 + 6/3 = 7 5 6 3 7 5 * 6/3 = 10 17 . % èEî‹-Þ¼ñ‹ ÞìI¼‰¶ õô‹ +. — å¼ñ +. [ ] èEî‹ ÞìI¼‰¶ õô‹ H¡ªù£†´ ++. èí‚W†´‚ «è£¬õèœ ñFŠHìŠ ð´‹ õK¬êº¬ø¬ò M÷‚°A¡øù. - èEî‹-Þ¼ñ‹ ÞìI¼‰¶ õô‹ ܆ìõ¬í 2.

ã«î‹ æ˜ àœk´ float Þù‹ âQ™. M¬ì 3.66 âù‚ A¬ì‚°‹. 1 + pow (3. 2) = 10 18 .(5 + 6) /3 =3 ܬùˆ¶ àœk´èÀ‹ int Þù‹ â¡ð M¬ì 3 Ý°‹.

Þ„ªêòŸ°Pè¬÷‚ ªè£‡ì «è£¬õèœ. ñFŠHìŠð´‹ º¬øè¬÷ ܆ìõ¬í 2. 2) * [ (3 + 2) (8 .7-™ 裇è.1 + pow (3. 19 .7) + 2 ] = 55 I°Š¹. °¬øŠ¹„ ªêòŸ°Pèœ C ªñ£NJ™ àœ÷õ£«ø C++ ªñ£NJ½‹ ªêò™ð´ˆîŠð´A¡øù.

â¡Â‹ ñ£PJ™ Þ¼ˆîŠð´‹. âù«õ. ªêòô£‚è‹: a = a-1. c = a. a -- a-¡ ñFŠ¬ðŠ ªðŸÁ ܉î ñFŠH™ 1 °¬ø‚辋 a=5. ÞŠ«ð£¶ c. c = a. c.6 I°Š¹. ªêòô£‚è‹: c = a. ªêòô£‚è‹: c = a. c = a++. c = ++a. c = a--. a = a-1. °¬øŠ¹„ ªêòŸ°Pèœ 20 .¡ ñFŠ¹ â¡ùõ£è Þ¼‚°‹? --a a-¡ ñFŠH™ 塬ø‚ °¬øˆ¶ ܉î ñFŠ¬ðŠ ªðÁè a = 5. c â¡Â‹ ñ£PJ™ Þ¼ˆîŠð´‹ ñFŠ¹ 5 Ý°‹. ++a a-¡ ñFŠH™ 1 I°ˆ¶ ܉î ñFŠ¬ðŠ ªðÁè a = 5. ÞŠ«ð£¶ c-¡ ñFŠ¹ â¡ùõ£è Þ¼‚°‹? ܆ìõ¬í 2. c = --a. a = a+1. ñFŠ¹ 6 Ý°‹. âù«õ.«è£¬õ ªêò™ð£´ â´ˆ¶‚裆´ a++ a-¡ ñFŠ¬ðŠ ªðŸÁ ܉î ñFŠH™ 1 I°‚辋 a = 5. ªêòô£‚è‹: a = a+1.

- ñ£PJ™ Þ¼ˆîŠð´‹ ñFŠ¹èœ fun-™_______ sim-™______ final-™______ ܆ìõ¬í 2.7. x = 10.™ îóŠð†´œ÷ è†ì¬÷ˆ ªî£°FèO™ ñ£PèO™ Þ¼ˆîŠð´‹ ñFŠ¹èœ â¡ùõ£è Þ¼‚°‹? 1. final= .2. ñ£PJ™ Þ¼ˆîŠð´‹ ñFŠ¹_____ ñ£PJ™ Þ¼ˆîŠð´‹ ñFŠ¹èœ c-™_______ x-™_______ f-™_______ 3.-fun + ++sim-fun. a = a+b++.܆ìõ¬í 2. W›‚è£μ‹ Gð‰î¬ùè¬÷ ܬñ‚è åŠd†´„ ªêòŸ°Pèœ ðò¡ ð†´œ÷ù. b = 5.7. sim=2. f = 20. â´ˆ¶‚裆ì£è. c = x++ + ++f.5 • 9 == 9 21 . • 10 > 20 • 500. åŠd†´„ ªêòŸ°PèO¡ ð†®ò™: • == Gèó£ù¶ • > M슪ðK¶ • < Mì„CP¶ • >= M슪ðK¶ Ü™ô¶ Gè˜ • <= Mì„CP¶ Ü™ô¶ Gè˜ • != GèK™¬ô åŠd†´„ ªêòŸ°Pèœ ñFŠ¹è¬÷ åŠHìŠ ðò¡ð´ˆîŠð´A¡øù.2 åŠd†´„ ªêòŸ°Pèœ (Relational Operators) ñFŠ¹è¬÷ åŠHì åŠd†´„ ªêòŸ°Pèœ ðò¡ð´ˆîŠð´A¡øù. fun=1. 2. Þó‡´ ªêò«ôŸHèœ æ˜ åŠd†´„ ªêòŸ°Pò£™ Þ¬í‚èŠð†´ åŠd†´‚ «è£¬õèœ Ü¬ñ‚èŠð´A¡øù. a = 5.7 âOò Mù£‚èœ 2.45 <= 1005 • 99 != 99.

num2=20. âù«õ å¼ ²NòI™ô£ ñFŠ¹) 1 (9==9 â¡ð¶ êK. ⇠ñ£PL 0 (²Nò‹) îõÁ (false) â¡Â‹ ñFŠ¬ð‚ °P‚Aø¶.5 â¡ð¶ êK. «ñŸè‡ì «è£¬õèO¡ ªõOf´ Þšõ£Á Þ¼‚°‹: • • • • 0 (10>20 â¡ð¶ îõÁ) 1 (500. âù«õ å¼ ²NòI™ô£ ñFŠ¹) 1 (99!=99.åŠd†´„ ªêò™ð£´.45<1005 â¡ð¶ êK. âù«õ å¼ ²NòI™ô£ ñFŠ¹) W›‚è£μ‹ «è£¬õJ¡ ñFŠ¹ â¡ùõ£è Þ¼‚°‹? num1=99. ²Nò‹ Ü™ô£î â‰î ⇠ñFŠ¹‹ êK (true) â¡ð¬î‚ °P‚°‹.8 åŠd†´‚ «è£¬õè¬÷ ñFŠH´è 22 . êK (true) Ü™ô¶ îõÁ (false) â¡Aø M¬ì¬òˆ . num3=10 âQ™ (num1+num2-num3)/5*2<(num1%10) âšõ÷¾? ܆ìõ¬í 2.8 -™ àœ÷ åŠd†´‚ «è£¬õè¬÷ ñFŠH´è: ªêòŸ°P «è£¬õ == 5==6 != ‘a’!=’a’ > 5>6 M¬ì 0 ‘a’>’A’ < 5<6 ‘a’<‘A’ >= ‘a’>=’z’ 5>=5 <= ‘a’<=’z’ 5<=6 ܆ìõ¬í 2.

Result_4-™ àœ÷ ñFŠ¹ 0 (îõÁ) 23 . Result_1 = (c == d) && (choice != term) Result_2 = (‘y’ == ‘Y’) || (term != ‘0') Result_3 = (c==d) &&(‘y’ == ‘Y’) || (choice != term) Result_4 = (c==d) || (‘y’ == ‘Y’) && (choice != term) Result_1. èí‚W†´„ ªêòŸ°Pè¬÷Mì‚ °¬ø‰î º¡ÂK¬ñ à¬ìò¬õ. â´ˆ¶‚裆ì£è. || (OR) ! (NOT) – ÝAò¬õ î¼‚è„ ªêòŸ°Pèœ Ý°‹. x+y*z< e/f â¡Â‹ «è£¬õ Þšõ£Á ñFŠHìŠð´‹: 2.7.2.åŠd†´„ ªêòŸ°Pèœ. choice=’y’. Result_2-™ àœ÷ ñFŠ¹ 1 (êK) Result_3-™ àœ÷ ñFŠ¹ 1 (êK). && (AND). term=’2' (êK â¡ð¬î 1 âù¾‹. îõÁ â¡ð¬î 0 âù¾‹ è¼F‚ ªè£œè).3 î¼‚è„ ªêòŸ°Pèœ (ÌLò¡ ªêòŸ°Pèœ) å¡Á Ü™ô¶ å¡Á‚° «ñŸð†ì Gð‰î¬ùèO¡ M¬ìè¬÷ î¼‚è„ ªêòŸ°Pèœ å¡P¬í‚A¡øù. d=6. Result_2 ÝAòõŸP™ Þ¼ˆîŠð†ì ñFŠ¹ ò£¶? Result_1-™ àœ÷ ñFŠ¹ 0 (îõÁ). â´ˆ¶‚裆´: c=5.

Result_1 = (c == d) && (choice != term) ñFŠ¹è¬÷Š ðFh´ ªêŒJ¡ îõÁ Result_2 = (‘y’ == ‘Y’)&& (term != ‘0’) ñFŠ¹è¬÷Š ðFh´ ªêŒJ¡ êK 24 .

1 êK 25 .Result_3 = (c == d) && (‘y’ = = ‘Y’) || (choice != term) ñFŠ¹è¬÷Š ðFh´ ªêŒJ¡.

Result_4 = (c == d) || (‘y’ = = ‘Y’) && (choice != term) ñFŠ¹è¬÷Š ðFh´ ªêŒJ¡. îõÁ 26 .

7.î¼‚è„ ªêòŸ°Pèœ. ? : â¡ð¶ º‹ñ„ ªêòŸ°P. E3. E1? E2: E3. E2. âù‚ è†ì¬÷ ܬñ‚èô£‹. Þ™¬ô«ò™. ßÁè÷£è«õ£ Þ¼‚èô£‹. (num1>num2). åŠd†´„ ªêòŸ°Pèœ ñŸÁ‹ èí‚W†´„ ªêòŸ°Pè¬÷Mì‚ °¬ø‰î º¡ÂK¬ñ ªè£‡ì¬õ. “îõÁ” . (num1>num2) ? “êK”: “îõÁ”. E2.ÝAò¬õ ªêò«ôŸHèœ.îõÁ 2. Þ„ªêòŸ°PJ¡ ªð£¶õ£ù è†ì¬÷ ܬñŠ¹. “êK”. H¡õ¼‹ «è£¬õJ¡ ñFŠ¬ð‚ è‡ìPò º®»ñ£? 5<4 && 8+9 0 . max=(num1>num2) ? num1: num2. E1 â¡ð¶ å¼ Gð‰î¬ùò£è Þ¼‚°‹. max-™ num2 Þ¼ˆîŠð´‹. âù ܬñ»‹. ÝAò¬õ ªêò«ôŸHèœ Ý°‹. â´ˆ¶‚裆ì£è.4 Gð‰î¬ù„ ªêòŸ°P (?:) (Conditional Operator) Gð‰î¬ù„ ªêòŸ°P.2. E3 ÝAò¬õ ñFŠ¹è÷£è«õ£. âù ܬñ»‹. Þó‡´ â‡èO™ ªðKò ⇬í å¼ ñ£PJ™ Þ¼ˆ¶õ. 27 . º‹ñ„ ªêòŸ°P¬ò Gð‰î¬ù„ ªêòŸ°P â¡Á‹ ܬö‚A«ø£‹. E1. num1 â¡Â‹ ñFŠ¹ num2-ä‚ è£†®½‹ ªðK¶ âQ™ max-™ num1 Þ¼ˆîŠð´‹.

c=7 âQ™ W›‚è£μ‹ «è£¬õèO¡ ñFŠ¬ð‚ 裇è: a += b*c c *= a + a / b b += a % 2 * c ܆ìõ¬í 2.J™ Þ¼ˆîŠð´‹ A=A*4 A. ñFŠ¬ðŠ ªðÁAø¶ A += 2 A += 2 â¡ðî¡ ªð£¼œ A = A +2 Ý°‹.W«ö»œ÷ è†ì¬÷ˆ ªî£°FJ™.2. A. 2. b = 10. x = (a<b)? a*a : b%a. ܬùˆ¶ ñFŠH¼ˆ¶ ªêòŸ°P è¬÷»‹ W«ö»œ÷ ܆ìõ¬í 2. M¬ì¬ò å¼ ñ£PJ™ (ªêòŸ°P J¡ ÞìŠð‚è‹ Þ¼‚°‹) Þ¼ˆ¶õ Þ¶ ðò¡ð´ˆîŠð´Aø¶. ñFŠ¹ 20.7. a=5. å¼ «è£¬õJ¡ (ªêòŸ°PJ¡ õôŠð‚è‹ Þ¼‚°‹). A-=2 A=A–2 A. x â¡Â‹ ñ£PJ™ Þ¼ˆîŠð´‹ ñFŠ¹ â¡ùªõ¡Á ªê£™ô º®»ñ£? a = 10.9-™ 裇è. A %= 2 A.J™ Þ¼ˆîŠð´‹ ñFŠ¹ 3. Þ‰î„ ê£î£óí ñFŠH¼ˆ¶ ªêòŸ°P îMó «õÁ ðˆ¶ °Á‚°õN ñFŠH¼ˆ¶ ªêòŸ°PèÀ‹ àœ÷ù.J™ Þ¼ˆîŠð´‹ A= A%2 ñFŠ¹ 1.5 ñFŠH¼ˆ¶ ªêòŸ°Pèœ (Assignment Operators) = â¡ð¶ ê£î£óí ñFŠH¼ˆ¶ ªêòŸ°P Ý°‹.J™ Þ¼ˆîŠð´‹ A *= 4 ñFŠ¹ 7.9. ñFŠH¼ˆ¶ ªêòŸ°Pèœ 28 . «è£¬õ ªêòô£‚è‹ M¬ì A=5 A â¡Â‹ ñ£PJ™ 5â¡Â‹ ñ£P 5 â¡Â‹ ñFŠ¹ Þ¼ˆîŠð´Aø¶.J™ Þ¼ˆîŠð´‹ ñFŠ¹ 2. A /= 2 A=A/2 A. b=6.

å¼ñ - èEî å¼ñ‹ èEî å¼ñ‹ è å¼ñ‹ èEî å¼ñ‹ õôI¼‰¶ Þì‹ õôI¼‰¶ Þì‹ õôI¼‰¶ Þì‹ ÞìI¼‰¶ õô‹ * / % èEî Þ¼ñ‹ ÞìI¼‰¶ õô‹ +- èEî Þ¼ñ‹ ÞìI¼‰¶ õô‹ < <= > >= åŠd†´ Þ¼ñ‹ ÞìI¼‰¶ õô‹ = = != åŠd†´ Þ¼ñ‹ ÞìI¼‰¶ õô‹ && (AND) è Þ¼ñ‹ ÞìI¼‰¶ õô‹ || (OR) è Þ¼ñ‹ ÞìI¼‰¶ õô‹ ?: î¼‚è º‹ñ‹ ÞìI¼‰¶ õô‹ = *= /= %= += -= <<= >>= &= ^= |= ñFŠH¼ˆî™ õôI¼‰¶ Þì‹ Ü†ìõ¬í 2.10-™ 裇è. ªêòŸ°P º¡ÂK¬ñ õ¬è F¬êºè‹ ÞìI¼‰¶ õô‹ ÞìI¼‰¶ õô‹ () [] H¡ªù£†´ ++. — ! – è Þ™¬ô å¼ñ +. — .C++ ªñ£NJ™ ðò¡ð´ˆîŠð´‹ ܬùˆ¶„ ªêòŸ°PèO¡ º¡ÂK¬ñ¬ò»‹ G¬ø«õŸøŠð´‹ F¬êºèˆ¬î»‹ ܆ìõ¬í 2. º¡ªù£†´ ++.10 ªêòŸ°P º¡ÂK¬ñ (°PŠ¹: C++ ªñ£N‚«è àKò CøŠ¹„ ªêòŸ°Pèœ Ü‰î‰îŠ ð£ìƒèO™ M÷‚èŠ ð´‹) 29 .

GÁˆîŸ °Pè¬÷»‹ ÜõŸP¡ ðò¡ð£†¬ì»‹ ܆ìõ¬í 2.3 îó¾ Þùƒèœ (Data Types) å¼ Góô£‚è ªñ£NJ™ ¬èò£÷Šð´‹ ñ£Pèœ åšªõ£¡Á‹ °PŠH†ì õ¬è ñFŠ¹è¬÷«ò 㟰‹. [ ] æ˜ ÜEJ¡ °PŠH†ì àÁŠ¬ð„ ²†´A¡ø ²†ªì‡ (Index) Þ‰î ܬ승‚ °PèÀ‚°œ Þ싪ðÁ‹. ’ ” êó‹ Þ‰î «ñŸ«è£œ °PèÀ‚°œ Þ싪ðÁ‹.8 GÁˆîŸ °Pèœ (Punctuators) GÁˆîŸ °Pèœ â¡ð¬õ °PŠH†ì ðE¬ò„ ªêŒ»‹ °P»¼‚ è÷£°‹. /* */ ÞõŸP™ àœ÷ìƒAò à¬óˆªî£°F °PŠ¹¬óò£è‚ è¼îŠð´‹.11 GÁˆîŸ °PèÀ‹ ÜõŸP¡ ðò¡ð£´‹ 2. 30 .2. ‘ “ 埬ø‚ °P»¼ Þ‰î «ñŸ«è£œ °PèÀ‚°œ îóŠð´‹.11-™ 裇è. GÁˆîŸ °P ðò¡ð£´ å¼ C++ è†ì¬÷¬ò º®ˆ¶ ¬õ‚Aø¶ . ܆ìõ¬í 2. îó¾è¬÷Š ð™«õÁ õ¬èJùƒè÷£èŠ HKˆî¬ñŠð Þó‡´ è£óíƒèœ àœ÷ù: • 嚪õ£¼ îóMùˆ¶‚°‹ Gó™ªðò˜ŠH (Compiler) àKò ÜèG¬ô à¼õAŠ¬ðŠ ðò¡ð´ˆF‚ ªè£œÀ‹. Þˆî¬èò îóM¡ õ¬èè¬÷«ò îó¾ Þùƒèœ (Data Types) â¡A«ø£‹. C‚è™ I°‰î ªð£¼œ è¬÷ Gó™èO™ â´ˆî£À‹ ðE¬ò âO¬ñò£‚°Aø¶. { } C++ è†ì¬÷è¬÷ å¼ ªî£°Fò£è‚ °P‚èŠ ðò¡ð´Aø¶. å¼ ªêòŸÃP¡ è†ì¬÷ˆ ªî£°F Þ‰î ܬ승‚ °PèÀ‚°œ Þ¼‚°‹.2. // °PŠ¹¬óèÀ‚°Š (Comments) ðò¡ð´ˆîŠð´Aø¶. C++ ªñ£NJ™ îó¾è¬÷ «õÁð†ì Þùƒè÷£èŠ HKˆ¶‚ è£μ‹ Fø¡.

îóMùƒè¬÷ ºŠªð¼‹ õ¬èJùƒè÷£èŠ HK‚èô£‹: • • • ðòù˜ õ¬óòÁ‚°‹ îóMù‹ (User defined type) àœO¬í‰î îóMù‹ (Built-in type) î¼M‚èŠð†ì îóMù‹ (Derived type) «ñŸè‡ì ðó‰î õ¬èŠð£†®¬ù à†HK¾è«÷£´ ðì‹ 2.2-™ 裇è: C++Data îóMùƒèœ C++ Types ðòù˜ õ¬óòÁŠð¬õ User Defined type 膴¼(Structure) Structure Æ´¼(Union) Union Þù‚°¿ (Class) Class â‡μ¼ (Enumeration) Enumeration º¿â‡ Integral typeõ¬è int àœO¬í‰î¬õ Built .1 ðòù˜ õ¬óòÁ‚°‹ îóMù‹ (User defined data type) Góô˜ î¡Â¬ìò ªê£‰îˆ îóMùƒè¬÷»‹.in type (Ü®Šð¬ìˆîóMùƒèœ) fundamental) î¼M‚èŠð†ì¬õ Derived type ÜE Array(Array) ªêòŸÃÁ Function (Function) ²†´ (Pointer) Pointer °PŠ¹ (Reference) Reference I Floating typeõ¬è void float char double ðì‹ 2. 31 .• Gó™è¬÷ à¼õ£‚°‹ Góô˜ 嚪õ£¼ îóMùˆ¶‚°‹ ãŸø ªêòŸ°Pè¬÷Š ðò¡ð´ˆF‚ªè£œ÷ º®»‹. å¼ GóL¡ 𮊪ðO¬ñ¬ò (readability) «ñ‹ð´ˆî Þ¶ àî¾Aø¶. ܬõ ãŸA¡ø ñFŠ¹è¬÷»‹ õ¬óòÁˆ¶‚ªè£œ÷ õ¬è ªêŒòŠð†´œ÷¶.2 C++ îóMùƒèœ 2.3.

3 ðòù˜ õ¬óòÁˆî îóMù‹ ðòù˜ õ¬óòÁˆî student â¡Â‹ îóMù‹ Þù‚°¿ (class) â¡Â‹ îó¾ õ¬è¬ò„ ꣘‰î¶. Þù õ¬óò¬ø (Type definition) â¡Â‹ õêF ðòù˜. 32 . å¼ ñ£íõK¡ Mõóƒè¬÷Š ªðø¾‹. W«ö»œ÷ ðòù˜ õ¬óòÁˆî îóMùˆ¬î‚ 裇è: ðòù˜ õ¬óòÁˆî îóMùˆF¡ ªðò˜ student àÁŠ¹ ñ£Pèœ àÁŠ¹„ ªêòŸÃÁèœ ðì‹ 2. ÜîŸè£ù è†ì¬÷ ܬñŠ¹: typedef <îóMù‹> <ðòù˜ õ¬óòÁ‚°‹ îóMù‚ °PŠªðò˜>. Þšõ£Á. îóMù‚ °PŠªðò˜è¬÷ à¼õ£‚A‚ ªè£œ÷ ÜÂñF‚Aø¶. â´ˆ¶‚裆´: typedef int marks. 㟪èù«õ Gô¾‹ å¼ îóMùˆ¶‚°Š ðòù˜ å¼ ¹Fò ªðò¬ó„ ņ®‚ªè£œ÷ º®»‹. ÜšMõóƒ è¬÷ˆ F¬óJ™ 裆쾋 ªêòŸÃÁèœ õ¬óòÁ‚èŠð†´œ÷ù. àÁŠ¹ ñ£Pèœ. class student â¡Â‹ îóMù‹ «î¬õò£ù îó¾è¬÷»‹ ÜõŸ«ø£´ ªî옹¬ìò ªêòŸÃÁè¬÷»‹ ñ£íõ˜‚è£ù å¼ ¹Fò îóMù õ®M™ å¡ø£èŠ H¬íˆ¶ ¬õˆ¶œ÷î¡ Íô‹ GóL¡ îóˆ¬î»‹ 𮊪ðO¬ñ¬ò»‹ «ñ‹ð´ˆF»œ÷¶. ÜõŸ«ø£´ ªî£ì˜¹¬ìò ªêòŸÃÁèO¡ õ®M™ å¼ ñ£íõK¡ ðKñ£íƒè¬÷ Þ¶ õ¬óòÁˆ¶œ÷¶.â´ˆ¶‚裆ì£è. typedef char grade.

grade eng_grade.. Tuesday.. ðòù˜èœ °PŠªðò˜èO¡ ð†®ò¬ô å¼ îóMùñ£è õ¬óòÁˆ¶‚ ªè£œ÷ ÞˆîóMù‹ àî¾Aø¶... «ñŸè‡ì ñFŠH¼ˆî™ è†ì¬÷è¬÷ Þšõ£Á‹ â¿îô£‹. enum holidays (Sunday.. last_workingday â¡Â‹ ñ£Pè¬÷‚ W›‚è£μñ£Á ÜPM‚è º®»‹: working_days first_workingday. â´ˆ¶‚裆´èœ: enum working_days (Monday.. grade ÝAò¬õ ðòù˜ õ¬óòÁˆî îóMù‚ °PŠªðò˜ è÷£°‹..) â¡ð¶ â‡μ¼ ñ£PLèœ Ü™ô¶ â‡õ¬è ñ£PLèœ â¡Á ܬö‚èŠð´‹ ñFŠ¹è¬÷‚ ªè£‡ì ð†®òô£°‹. ÝAò¬õ Üè G¬ôJ™ Gó™ªðò˜ŠHò£™ º¡Qò™ð£è 0-M™ ªî£ìƒA 1..ñ£Pn. working_days.. char ñ£Pè¬÷ Þšõ£Á õ¬óòÁ‚èô£‹: marks eng_marks. Saturday). Thursday. ñ£P2.... âù õK¬êò£ù int ñ£PLè÷£è«õ ¬èò£÷Šð´A¡øù. è†ì¬÷ ܬñŠ¹: enum <îóMù‚ °PŠªðò˜> (ñFŠ¹1.. int Þù‚ °Pf†´ â‡õ¬è ñ£PL â¡Á‹ Þî¬ù ܬöŠð˜. ܬõ GóL¡ 𮊪ðO¬ñ¬ò «ñ‹ð´ˆ¶A¡øù.. math_marks.. last_workingday. working_days â¡Â‹ îóMùˆF™ first_workingday.. holidays ÝAò °PŠªðò˜èœ ðòù˜ õ¬óòÁˆî îóMùƒèœ Ý°‹. â´ˆ¶‚裆ì£è.... ñFŠ¹2.. Þ‰î â‡μ¼ˆ îóMùˆF™ ðòù˜èœ W›‚è£μñ£Á ñ£Pè¬÷ ÜPM‚èô£‹: enum <°PŠªðò˜> ñ£P1.... âù«õ.. last_workingday = Friday... 3. 33 . ðòù˜ õ¬óòÁ‚°‹ Þ¡ªù£¼ îóMù‹ â‡μ¼ˆ îóMùñ£°‹.marks. Wednesday. Wednesday.. °PŠªðò˜ ñ£PLèœ Monday. math_grade.... ðòù˜èœ int. Þ‰î ñ£Pèœ working_days ÞùˆF™ õ¬óòÁ‚èŠð†´œ÷ ñFŠ¹èO™ 塬ø ñ†´«ñ 㟰‹. Friday).. ªð£¼œ ªð£F‰î îóMù‚ °PŠªðò˜è¬÷ à¼õ£‚A‚ ªè£œ÷ typedef àî¾Aø¶.. (Monday. ñFŠ¹ n ). first_workingday = Monday. Tuesday. Tuesday. 2.

auto. auto ñ£Pèœ.. Tuesday. ÞF™ Monday â¡ð¶ 1 â¡ø ñFŠ¬ðŠ ªðÁ‹. enum working_days (Monday=1. °PŠªðò˜ ñ£PLèÀ‚° ªõOŠð¬ìò£è «õÁ ⇠ñFŠ¹è¬÷‚ °PŠH†´ int ñ£PLè¬÷ Þšõ£Á ñÁõ¬óò¬ø ªêŒ¶ªè£œ÷ º®»‹. register ÝAò Þù ñ£PèO™ ܬõ ÜPM‚èŠð´‹«ð£«î 0 â¡ø ªî£ì‚è ñFŠ¹ î£ù£è«õ Þ¼ˆîŠð†´ M´Aø¶.. °Š¬ð (Garbage) âùŠð´‹ õ¬óòÁ‚èŠðì£î ñFŠ¹è¬÷Š ªðÁA¡øù. static. 2. ðòù˜èœ. static. auto Þù ñ£PèO™ Üšõ£Á îóMùˆF¡ Ü®Šð¬ìJ™ ãŸø ñFŠ¹èœ ªî£ì‚è ñFŠð£è Þ¼ˆîŠð´õF™¬ô. Wednesday. âù Ü´ˆî´ˆî int ñ£PL ñFŠ¹è¬÷Š ªðÁ‹. Ü´ˆ¶œ÷ ñ£PLèœ 2. Thursday.3. «êIŠ¹ ÞùƒèÀ‚è£ù ªð£¼À‹. extern. ªð£¼ˆîñ£ù â´ˆ¶‚裆´èÀ‹ ܆ìõ¬í 2. register â¡Â‹ ° õ¬èò£ù «êIŠ¹ Þùƒèœ àœ÷ù.12-™ õöƒèŠ ð†´œ÷ù: 34 .first_workingday = 0.. 3.2 «êIŠ¹ Þù‹ (Storage Class) å¼ ñ£PJ¡ ÜPMŠ¹‚° º¡£™ «êIŠ¹ Þù‹ â¡Â‹ î°F ò£‚A¬ò (qualifier) ެ툶‚ªè£œ÷ º®»‹. last_workingday = 4. Friday). 4.

âù«õ auto â¡Â‹ «êIŠ¹ ÞùŠªðò˜ ªð¼‹ð£½‹ °PŠHìŠð´õF™¬ô. count ÝAò ñ£P èœ main()ªêòŸÃÁ‚°œ õ¬óòÁ‚èŠð†´œ÷ù.12 «êIŠ¹ Þù‚°¿‚èœ 35 . } ratio. ÞõŸ¬ø Iè «õèñ£Œ Üμè º®»‹. å¼ ªêòŸÃPÂœ Ü™ô¶ ªî£°F‚°œ õ¬óòÁ‚èŠð´‹ ñ£Pèœ Ü‰î ªêòŸÃÁ Ü™ô¶ ªî£°F ªêò™ð†´ º®‰î¾ì¡ ÜN‰¶ «ð£A¡øù. void main() { auto float ratio. } ܆ìõ¬í 2. auto int count. Þ¬õ ÜPM‚èŠð´‹ ªî£°F‚°œ ñ†´«ñ ÜPòŠ ð´‹. register â¡Â‹ ð‡¹í˜ˆF. àœ÷è ñ£Pèœ Ü¬ùˆ¶‹ auto Þùˆ¬î„ ꣘‰î¬õ«ò. º¡Qò™ð£è«õ. void fun() { register int i. Þ‰î ñ£Pèœ «õªø£¼ GóL™ õ¬óòÁ‚èŠð†®¼‚°‹. Þ‰î õ¬è¬ò„ ꣘‰î ñ£Pèœ.܉î ñ£Pèœ è¬ìCò£è Þ¼ˆîŠð†ì ñFŠ¹è¬÷ˆ î‚è ¬õˆ¶‚ ªè£œA¡øù. x++. Þ¬õautoâ¡Â‹«êIŠ¹ Þùˆ¬î„ «ê˜‰î¬õ void fun() { static int x.«êIŠ¹ Þù‹ auto static extern register ªð£¼œ â´ˆ¶‚裆´ àœ÷è ñ£Pèœ (local variables) . extern void factorial(). } extern int filemode. ï승 GóL™ ܬùˆ¶ ªêòŸÃÁ èO½‹ ðò¡ð´ˆî‚îò º¿î÷£Mòñ£Pèœ(global variables) Ý°‹. Üšõ£P¡P ñ£Pèœ Ü¬õ ÜPM‚èŠð´‹ ªêòŸÃÁ Ü™ô¶ ªî£°F ªêò™ ð†´ º®‰îH¡Â‹ èEŠªð£P G¬ùõèˆF™ îƒAJ¼‚è static â¡Â‹ ð‡¹í˜ˆF(Modifier)õ¬è ªêŒAø¶. Üšõ£Á ÜPM‚èŠð´‹ ñ£Pè¬÷ Cd»M¡ ðFõèƒèO™ (registers) Þ¼ˆF¬õ‚°ñ£Á Gó™ªðò˜ŠH‚° à혈¶Aø¶.

1.. â´ˆ¶‚裆ì£è. char â¡ð¶ °P»¼ˆ îóMù‹.cpp ÝAò C++ Gó™èO™ õ¬óòÁ‚èŠð†´œ÷ ªêòŸÃÁè¬÷ «ï£‚°è: 36 . ch â¡Â‹ ñ£PJ¡ ÜPMŠ¬ð»‹. ÜF™ ªî£ì‚è ñFŠH¼ˆî¬ô»‹ 裇è: char ch = ‘A’. int. Ü®Šð¬ìˆ îóMùƒè¬÷ º¿â‡ (integral). Þ«î è†ì¬÷¬ò. char ÝAò îóMùƒè¬÷ àœ÷ì‚Aò¶. âù º¿â‡ ñFŠ¹è¬÷«ò 㟰‹. double ÝAò îóMùƒè¬÷ àœ÷ ì‚Aò¶.. ñFŠHLˆ îóMù‹ (void type) Þó‡´ õ¬èJ™ ðò¡ð´A¡øù: • å¼ ªêòŸÃÁ â‰î ñFŠ¬ð»‹ F¼ŠH ÜŠ𣶠â¡ð¬î‚ °P‚è • ªð£¶ Þù„ ²†®¬ù (generic pointer) ÜPM‚è â´ˆ¶‚裆ì£è. int îóMù‹. â¡Á‹ ÜPM‚èô£‹. char ch = 65. ch â¡Â‹ ñ£PJ™ ‘A’ â¡Â‹ ⿈¬î Þ¼ˆ¶A¡øù. Iõ¬èˆ îóMù‹ H¡ùŠ ð°F»ì¡ îò ⇠ñFŠ¹ è¬÷ Þ¼ˆF¬õ‚°‹ Fø¡ ð¬ìˆî¬õ. (65 â¡ð¶ A â¡Â‹ ⿈F¡ Ýv‚A ñFŠ 𣰋).. I(float).cpp. (IŠ ¹œO ñ£PLèœ ðŸP 㟪èù«õ 𮈶œ÷¬î G¬ù¾ Øè)..2. «ñŸè‡ì Þó‡´ ÃŸÁèÀ‹ å«ó ðE¬ò«ò G¬ø«õŸÁ A¡øù. º¿â‡ õ¬è. âQ‹ Þ¶ °P»¼ ñFŠ¹. º¿â‡ ñFŠ¹ ÝAò Þó‡¬ì»«ñ 㟰‹..4 àœO¬í‰î îóMùƒèœ (Built-in Data Types) àœO¬í‰î îóMùƒèœ Íôˆ îóMùƒèœ Ü™ô¶ Ü®Šð¬ìˆ îóMùƒèœ â¡Á‹ ܬö‚èŠð´A¡øù. H¡ù ñFŠ¹ è¬÷ ãŸè£¶. 3. Gó™ªðò˜ŠHJ™ ܬõ º¡õ¬óòÁ‚èŠð†´œ÷ù. fun. ñFŠHL(void) âù Í¡Á õ¬èò£èŠ HK‚èô£‹. 2. Iõ¬èˆ îóMù‹ float. W«ö»œ÷ void.3.

signed. ÜõŸP¡ õó‹¹ ñFŠ¹èœ ÝAòõŸ¬ø ܆ìõ¬í 2.void. G¬ùõèˆF™ ܬõ â´ˆ¶‚ ªè£œÀ‹ ¬ð† Ü÷¾.b) âù ܬñ‚èŠð†´œ÷¶. ðó‰î ÅöL™ «ï£‚Aù£™. îóMùƒèœ. long. Ü®Šð¬ìˆ îóMùƒèœ ð™«õÁ ð‡¹í˜ˆFè¬÷ (modifiers) ãŸA¡øù. ܬöŠ¹‚ ßÁ fun() â¡Á Þ싪ðŸÁœ÷¶. Ü„ªêòŸÃÁ â‰î ñFŠ¬ð»‹ F¼ŠHòŠ𣶠â¡ð¬î Gó™ªðò˜ŠH‚° à혈¶Aø¶. Ü÷¹¼‚èO¡ (parameters) õ®M™ âšMî ñFŠ¹è¬÷»‹ ãŸÁ‚ ªè£œ÷£¶ â¡ð¬î»‹ à혈¶Aø¶.13-™ 裇è. sum â¡Â‹ ñ£P return a+b â¡Â‹ è†ì¬÷ Íôñ£è int ñFŠH¬ùŠ ªðŸÁ‚ ªè£œAø¶. unsigned.  void îóMù‹. short ÝAò¬õ ÜõŸÁœ Cô ð‡¹í˜ˆFèœ Ý°‹. âù«õ main( ) ªêòŸÃP™. int b) â¡Â‹ º¡õ®¾ fun( ) ªêòŸÃÁ æ˜ int ñFŠ¬ðˆ F¼ŠHòŠ¹‹ â¡ð¬î Gó™ªðò˜ŠH‚° à혈¶Aø¶. Þ‰îŠ ð‡¹í˜ˆFèœ ÜèG¬ôJ™ îó¾è¬÷ à¼õAŠðF™ Ýöñ£ù M¬÷¾è¬÷ ãŸð´ˆ¶A¡øù. âù«õ main() ªêòŸÃP™ ܬöŠ¹‚ ßÁ sum=fun(a. fun. void îóMù‹ â‰î ñFŠ¬ð»‹ ãŸè£¶ â¡ð¬î à혈¶Aø¶. 37 .cpp GóL™ ÜPM‚èŠ ð†´œ÷ int fun(int a.cpp GóL™ void cpp(void) âù ÜPM‚èŠð†´œ÷ º¡õ®¾ (prototype) Þ„ªêòŸÃÁ âšMî ñFŠ¬ð»‹ F¼ŠHòŠ𣶠â¡ð¬î»‹.

â´ˆ¶‚裆ì£è.4.4e+38 double 8 1. num_array[0] â¡Â‹ àÁŠH™ 1 Þ¼‚°‹.5}. ÜEJ½œ÷ åš«õ£˜ àÁŠ¹‹ Üî¡ Þ¼ŠHì„ ²†ªì‡ õNò£è ÜμèŠð´Aø¶. Þ¼ŠHì ⇠0 ML¼‰¶ ªî£ìƒ°Aø¶. dayname[0]. dayname[5].4e-4932 to 1.signed long int 4 -2147483648 to 2147483647 unsigned long int 4 0 to 4294967295 float 4 3. “Fri”. “Tue”. num_array [4] â¡Â‹ àÁŠH™ 5 Þ¼‚°‹.3. char dayname [7] [4] = { “Sun”. dayname[3][2] ÝAò àÁŠ¹èO™ àœ÷ ñFŠ¹èœ ⡪ù¡ù â¡ð¬î‚ Ãø º®»ñ£? 38 .2. num_array 5 ñFŠ¹è¬÷‚ ªè£‡´œ÷¶. “Thu”.7e-308 to 1. “Mon”. unsigned short int signed int.Type Byte Range char 1 -128 to 127 unsigned char 1 0 to 255 signed char 1 -128 to 127 int 2 -32768 to 32767 2 0 to 65535 signed short int 2 -32768 to 32767 long int. ܆ìõ¬í 2.13 îóMùƒèÀ‹ ÜõŸP¡ Ü÷¾‹ õó‹¹ ñFŠ¹èÀ‹ 2.short int. float «ð£¡ø àœO¬í‰î Ü®Šð¬ìˆ îóMùƒèœ Ü™ô¶ ðòù˜ õ¬óòÁ‚°‹ îóMùƒèOL¼‰¶ à¼õ£‚èŠð´ð¬õ Ý°‹.4e-38to3.4 î¼M‚èŠð†ì îóMùƒèœ (Derived Data Types) î¼M‚èŠð†ì îóMùƒèœ int. “Sat”}.7e+308 long double 10 3.1e+4932 unsigned int.3. ÜE (Array) õ¬èˆ îóMùˆF¡ ÜPMŠ¹/ñFŠH¼ˆî¬ô‚ 裇è: int num_array [5] = {1. “Wed”.

f ÝAò ñ£PèO¡ G¬ùõè Þ¼ŠHìƒèœ º¬ø«ò 1. W«ö»œ÷ ÜPMŠ¹è¬÷‚ 裇è: char c. 3 .1 ¬ð† int i .. â´ˆ¶‚裆ì£è. èEŠªð£P G¬ùõèˆF™ àœ÷ 嚪õ£¼ ¬ð†´‹ å¼ ºèõK¬ò‚ ªè£‡´œ÷ù.2 ¬ð†´èœ float f . Gó™ªðò˜ŠH.. â´ˆ¶‚裆ì£è.. âù õK¬êò£è ܬñ»‹.. char c . ïñ¶ i†´‚ èîªõ‡è¬÷Š «ð£ô. 640KB G¬ùõè Þò™ðì‹ ºî™ ºèõK Null 1 2 655358 655359 Last Address è¬ìC ºèõK ðì‹ 2. ïñ¶ â´ˆ¶‚ 裆®™. 640Kb Ü÷¾œ÷ G¬ùõè‹. i. NULL Þ™ ªî£ìƒA 6.55.4 640KB G¬ùõè Þò™ðì‹ å¼ Gó¬ô â‰Fó ªñ£N‚° ñ£ŸÁ‹«ð£¶.. int i.²†´èœ (Pointers) ²†´ â¡ð¶ å¼ G¬ùõè ºèõK¬ò 㟰‹ ñ£P Ý°‹..4 ¬ð†´èœ 嚪õ£¼ ñ£P»‹ Üî¡ ºèõK¬ò‚ ªè£‡«ì °PŠHìŠð´Aø¶. 2. ñ£P ꣘‰¶œ÷ îóMùˆ¶‚° ãŸð Ü 嶂èŠð´‹ G¬ùõèˆF¡ Þì Ü÷¾ ܬñAø¶. ºèõK â¡ð¶ æ˜ â‡í£°‹. 4 ¬ð†´è¬÷‚ ªè£‡®¼‚°‹.356 õ¬ó ºèõKè¬÷‚ ªè£‡®¼‚°‹. ºèõK ⇠â¡ð¶ NULL â¡ðF™ ªî£ìƒA 1. 39 . c. float f. ðì‹ 2. ñ£PèÀ‚°Kò G¬ùõè Þ¼ŠHìƒè¬÷ 嶂W´ ªêŒAø¶.. å¼ ñ£PJ¡ G¬ùõè Þ¼ŠHìˆ¬î «ïó®ò£è Üμ°õ ²†´èœ àî¾A¡øù.4 裇è. 2. ÞõŸP¡ ºèõKèœ ðFùÁñ ⇠º¬øJ™ °P‚èŠð´A¡øù..

. ñ£PJ¡ ªðò˜ (Þ¼ŠHìˆF¡ ªðò˜) num1 îó¾ (Þ¼ŠHìˆF™ Þ¼ˆîŠð†´œ÷ ñFŠ¹) 10 0X8f90f2 num1 â¡ø ñ£PJ¡ G¬ùõè ºèõK // Program – 2. } 40 . “ <<&i.” << i.h> void main() { clrscr(). ‘&’ ªêòŸ°P: int num1=10. 3. C++ Gó™ªðò˜ŠH (C++ Compiler) W›‚è£μ‹ ªêò™ð£´è¬÷ ªêŒ¶ º®‚A¡ø¶: 1. â¡ø è†ì¬÷¬òˆ î‰î£™. ñFŠ¹ ²†ì™ (*) ÝAò ªêòŸ°Pè¬÷Š ðŸP ÜP‰¶ªè£œ÷ «õ‡´‹.1 // to demonstrate use of & operator #include<iostream. ܉î G¬ùõè Þ숶‚° num1 â¡ø ªðò¬ó„ ņ´Aø¶.h> #include<conio. ºèõK ²†ì™ (&)...²†´ˆ îóMùˆ¬î‚ ¬èò£œðõ˜. cout << “\n Address of the variable. int i = 10. getch(). cout << “\nValue stored in the variable . G¬ùõèˆF™ æ˜ int ñFŠ¬ð Þ¼ˆF¬õ‚è Þì‹ å¶‚W´ ªêŒAø¶ 2. G¬ùõèˆF™ ܉î ÞìˆF™ 10 â¡Â‹ ñFŠ¬ð Þ¼ˆ¶Aø¶.

4 ñ£Pèœ (Variables) °PŠH†ì õó‹ªð™¬ô‚°œ å¼ ñFŠH¬ù ãŸA¡ø å¼ îó¾Š ¹ôˆF¡ ªðò«ó ñ£P âùŠð´Aø¶. â¡Â‹ ßÁ “n â¡ð¶ int Þùˆ¬î„ «ê˜‰î ñ£P” â¡ø ªð£¼¬÷ à혈¶Aø¶.W«ö»œ÷ è†ì¬÷ˆ ªî£°F¬ò‚ 裇è: °PŠ¹: ï†êˆFó‚ °P (*) 1. 41 . Þ¶ æ˜ å¼ñ„ ªêòŸ°P (Unary Operator) Ý°‹. îó¾èœ Þ¼ˆîŠð´‹ G¬ùõè Þ¼ŠHìƒèÀ‚°Š ðòù˜ ņ´‹ ªðò˜è«÷ ñ£Pèœ Ý°‹. 2. num = 5. 2. 3. G¬ùõèˆF™ Þ¼ˆîŠð†´œ÷ ñFŠ¬ðˆ F¬óJ™ è£†ìŠ ðò¡ð†´œ÷¶ (ñFŠ¹ ²†ì™ ªêòŸ°P). num = 5. “5 â¡Â‹ ñFŠ¹ num â¡Â‹ ñ£PJ™ Þ¼ˆîŠð´Aø¶’’ â¡ø ªð£¼¬÷ à혈¶Aø¶. W«ö»œ÷ ßÁè¬÷‚ 裇è: int num. â´ˆ¶‚裆ì£è. å¼ ²†´ Þù ñ£P¬ò ÜPM‚èŠ ðò¡ð´ˆîŠð†´œ÷¶. int num. int num . â¡Â‹ ñFŠH¼ˆ¶ ßÁ.

f2. âù«õ.14 ñ£PŠ ªðò˜èO¡ 㟹ˆ î¬è¬ñ 2. ªðò˜èœ ⿈¶ õ®õ à혾 (Case Sensitive) àœ÷¬õ. ñ£P ꣘‰¶œ÷ îóMùˆF¡ Ü®Šð¬ìJ™ Gó™ªðò˜ŠH G¬ùõ般î 嶂°Aø¶. _Test Balance$ #one Include ܆ìõ¬í 2. ªðò˜èœ ⿈F™ Ü™ô¶ Ü®‚WP™ ªî£ìƒè «õ‡´‹. float f1. â´ˆ¶‚裆´ int q. CPò ⿈¶. ܆ìõ¬í 2.4. ÜPMŠ¹‚ ßP¡ ܬñŠ¹: îóMù‚ °PŠªðò˜ Þ¬ìªõO 42 ñ£PJ¡ ªðò˜ . â‡èœ.ñ£PJ¡ ªðò˜èœ ⿈¶èœ. choice. ªðKò ⿈F™ ܬñ»‹ ªðò˜èœ «õÁð´ˆF ÜPòŠð´A¡øù. ñ£P êKò£ùî£/ H¬öò£ùî£? A_b êKò£ù¶ 1a_b H¬öò£ù¶ H¬öò£ù¶ â¡ðîŸè£ù è£óí‹ ñ£PJ¡ ªðò˜ ⿈¶ Ü™ô¶ Ü®‚WP™î£¡ ªî£ìƒè «õ‡´‹. ñ£Pè¬÷Š ðò¡ð´ˆ¶õ º¡ð£è ÜõŸ¬øˆ îóMù‹ °PŠH†´ ÜPM‚è «õ‡´‹. Ü®‚WP™ ªî£ìƒ°‹ ªðò˜èœ ÜèG¬ô º¬ø¬ñ ñ£PèÀ‚è£ù (internal system variables) 嶂èŠð†´œ÷ù â¡ð¬î ÜPè. Üî£õ¶. char name [10]. Ü®‚WÁ (underscore) ÝAòõŸ¬ø‚ ªè£‡®¼‚èô£‹. âQ‹.14 -ä G¬ø¾ ªêŒè.1 ñ£PèO¡ ÜPMŠ¹ ñFŠ¹è¬÷ Þ¼ˆF‚ªè£œ÷ ñ£PèÀ‚° G¬ùõè‹ å¶‚èŠ ð´Aø¶.

long. Þ¶ îõø£ù ÜPMŠð£°‹. 16-õ¶ H† 1 âQ™ Üšªõ‡ âF˜ñ â‡. ÜèG¬ôJ™ 15 â¡Â‹ int ñFŠ¹ 00000000 00001111 â¡Á ¬èò£÷Šð´Aø¶. float. Ýù£™ void Þùˆ¶‚° ÞõŸ¬øŠ ðò¡ð´ˆî º®ò£¶. int. void. õôŠ¹ø‹ ªî£ìƒA 嚪õ£¼ H†ì£è Þ승ø‹ ܬñ‰¶ ªñ£ˆî‹ 15 H†´èœ ñFŠ¬ð Þ¼ˆîŠ ðò¡ð´ˆîŠð´A¡øù. int ñFŠ¹èœ Þ¼ñ ⇺¬øJ™ 16 H† õ®õ¬ñŠH™ Þ¼ˆF ¬õ‚èŠð´A¡øù. à„ê ñFŠ¹ H† (Most Sifgnificant Bit ) Ü™ô¶ °P H† (Sign Bit) âùŠð´Aø¶. area. 43 . Ýù£™ 裟¹œOò£™ HK‚èŠð†®¼‚è «õ‡´‹. Gó™ªðò˜ŠH ނßP¬ù Þšõ£Á ¹K‰¶ªè£œÀ‹: • side. float hypotenuse. unsigned ÝAò¬õ. «ï˜ñ ñFŠ¹ 0 ºî™ + 32767 õ¬ó. area ÝAò¬õ int Þù ñ£Pè÷£è‚ è¼îŠð´‹. hypotenuse. signed. CÁñ ñFŠ¹ -32768. long. âù«õ. float. àœO¬í‚èŠð†ì îó¾ ÞùƒèO¡ ð‡¹è¬÷ ñ£ŸPò¬ñ‚èŠ ðò¡ð´‹ ð‡¹í˜ˆFèœ (modifiers) Ü™ô¶ î°Fò£‚Aèœ (qualifiers) âùŠð´A¡øù. 0 âQ™ «ï˜ñ ⇠ݰ‹. “”float â¡Â‹ ªê£™½‚°Š Hø° 裟¹œO Þ싪ðø «õ‡´‹” â¡Â‹ H¬ö²†´‹ ªêŒF¬òˆ . short. îóMùƒè¬÷ ÜPMŠðèù char. double. âù«õ æ˜ int ñ£PJ™ Þ¼ˆîŠð´‹ ªð¼ñ ñFŠ¹ +32767. âù«õ «ñŸè‡ì ÜPMŠ¹‚ ßP¬ù Þšõ£Á ܬñ‚è «õ‡´‹:  å«ó Þùˆ¬î„ ꣘‰î å¡Á‚° «ñŸð†ì ñ£Pè¬÷ å«ó ÜPMŠ¹‚ ßP™ °PŠHì º®»‹. area â¡Â‹ float Þù ñ£Pè¬÷»‹ ÜPMŠð«î ïñ¶ «ï£‚è‹.int side. âF˜ñ ñFŠ¹ -1 ºî™ -32768 õ¬ó) 16-õ¶ H†. • side â¡Â‹ int Þù ñ£P¬ò»‹. short. â¡Â‹ ÜPMŠ¬ð â´ˆ¶‚ ªè£œ«õ£‹. unsigned ÝAò å¡ð¶ ªê£Ÿèœ ðò¡ð´ˆîŠð´A¡øù. è£óí‹. signed. (215 = 32768. Üšªõ‡ «ï˜ñ‹ (Positive) Ü™ô¶ âF˜ñ‹ (Negative) â¡ð¬î‚ °P‚Aø¶. Þ¶. hypotenuse.

const â¡Â‹ î°Fò£‚A (qualifier) GóL¡ Þò‚è «ïóˆF™ å¼ ñ£PJ¡ ñFŠ¹ ñ£ŸøŠðì º®ò£¶ â¡ð¬î à혈¶Aø¶. â´ˆ¶‚裆´: const float pi = 3. ð‡¹í˜Fè¬÷ˆ îóMùŠ ªðò¼‚° º¡ªù£†ì£èˆ îó «õ‡´‹. ð‡¹í˜ˆFèO¡ M¬÷¾èœ: • unsigned â¡Â‹ ð‡¹í˜ˆF. Üî£õ¶ 0 ºî™ 65535 õ¬ó Þ¼ˆF ¬õ‚èô£‹. «ï˜ñ‹/âF˜ñ‹ â¡ð¬î‚ °P‚°‹ °P H†¬ì»‹ ñFŠ¹í˜ˆîŠ ðò¡ð´ˆF‚ ªè£œõ ñ£P 㟰‹ ñFŠH¡ õó‹ªð™¬ô ñ£ŸPò¬ñ‚èŠð´Aø¶. âù«õ. ñFŠH¡ õó‹ªð™¬ô 216 õ¬ó Þ¼‚è º®»‹. signed char c. °P H†´‹ îó¾ ñFŠ¹‚è£è«õ ðò¡ð´ˆF‚ªè£œ÷Šð´‹. const î°Fò£‚A. const ñ£PJ¡ ñFŠ¬ð ñ£Ÿø ºò¡ø£™ Gó™ªðò˜ŠH H¬ö ²†´‹ ªêŒF¬òˆ .  ð‡¹í˜ˆF (modifier) æ˜ Ü®Šð¬ìˆ îóMùˆF¡ ð‡H¬ù ñ£ŸP¬òñˆ¶Š ¹Fò îóMùˆ¬î à¼õ£‚°Aø¶.  ñ£Pè¬÷ ÜPM‚°‹«ð£¶. 44 . • long â¡Á‹ ð‡¹í˜ˆF °PŠH†ì îóMùˆF¡ ¬ð†´è¬÷ ÜFèKˆ¶. ñFŠH¡ õó‹ªð™¬ô¬ò c†®‚Aø¶. Ü®Šð¬ìˆ îóMùˆF™ ñ£Pèœ ÜPM‚èŠð´‹«ð£¶.æ˜ int Þù ñ£PJ¡ ÜPMŠH™ unsigned â¡Â‹ ð‡¹í˜ˆF¬òŠ ðò¡ð´ˆFù£™ Ü‹ñ£PJ™ «ï˜ñ ñFŠ¹è¬÷ ñ†´«ñ Þ¼ˆî º®»‹. Hø ð‡¹í˜ˆFè¬÷Š «ð£¡«ø ñ£Pèœ ÜPM‚èŠð´‹«ð£¶ îóMùŠ ªðò¼‚° º¡ªù£†ì£è Þì‹ ªðÁAø¶.14. unsigned long int index. º¡ ªù£†ì£èŠ ð‡¹í˜ˆFèœ Þ싪ðø «õ‡´‹. unsigned int registration_number. â´ˆ¶‚裆ì£è.

int * iptr â¡Â‹ ÜPMŠ¹‚ ßÁ‚°.295 -2.768 to 32.767 -32.7 x 10308 3.483.147.15-™ 裇è: Data Types Type unsigned char char enum unsigned int short int int unsigned long long float double long double Length 8 bits 8 bits 16 bits 16 bits 16 bits 16 bits 32 bits 32 bits 32 bits 64 bits 80 bits Range 0 to 255 -128 to 127 -32.294. ²†´ ñ£PJ¡ ªðò˜ Þ‰î ñ£P.647 3.7 x 10-308to 1.4 x 1038 1.768 to 32.483. int Þù ñFŠ¹èœ Þ¼ˆF¬õ‚èŠð†´œ÷ å¼ ºèõK¬ò ñ†´‹ iptr ñ£P 㟰‹.648 to 2.535 -32.147.4 x 10-38to 3.767 0 to 4. iptr â¡ð¶ int Þùˆ¬î„ ²†´‹ å¼ ²†´ ñ£P (pointer variable) â¡Á ªð£¼œªè£œ÷ «õ‡´‹.967.767 0 to 65.1 x 104932 ܆ìõ¬í 2. ²†´ Þùˆ¬î„ «ê˜‰î¶ â¡ð¬î Gó™ªðò˜ŠH‚° à혈¶Aø¶ (ñ£P å¼ ºèõK¬ò 㟰‹) Þ‰î„ ²†´ æ˜ int Þùˆ îó¬õ„ ²†´Aø¶ â¡ð¬î‚ °P‚Aø¶.768 to 32.15 ð‡¹í˜ˆFèÀì¡ îóMùƒèœ ²†´ ñ£Pè¬÷ ÜPMˆî™ int * iptr.î°Fò£‚AèÀ‹ ð‡¹í˜ˆFèÀ‹ ðò¡ð´ˆ¶‹«ð£¶ H† â‡E‚¬è»‹ ñFŠH¡ õó‹ªð™¬ô»‹ ñ£ŸPò¬ñ‚èŠð´‹ îóMùƒè¬÷ ܆ìõ¬í 2.4 x 10-4932 to 1. 45 .

6. 46 . int x = f.2 ñ£Pè¬÷ˆ ªî£ìƒA¬õˆî™ (Initialization of Variables) ñ£Pè¬÷ ÜPM‚°‹«ð£«î ÜF™ °PŠH†ì ñFŠ¹ Þ¼ˆîŠ ð´õ¬îˆ ªî£ì‚è ñFŠH¼ˆî™ â¡A«ø£‹. int num = 10. àœÀ¬ø Þùñ£Ÿøƒèœ (Implicit Conversions) å¼ «è£¬õJ™ Þ싪ðÁ‹ îó¾èO¡ Þù‹ Gó™ªðò˜ŠHò£™ ñ£ŸøŠð´õ¶ àœÀ¬ø Þùñ£Ÿø‹ âùŠð´Aø¶. ºîô£õ¶ ßP™ num â¡Â‹ ñ£PJ™ 10 â¡Â‹ ªî£ì‚è ñFŠH¼ˆîŠð†´œ÷¶. cp-™ Þ¼ˆîŠ ð†´œ÷ ºèõK¬ò ñ£ŸPò¬ñ‚è º®ò£¶. â´ˆ¶‚裆ì£è.4.16 ²†´ ñ£PèÀ‚° â´ˆ¶‚裆´èœ 2. Þó‡ì£õ¶ ßP™ æ˜ Ý‚A (constructor) Íô‹ 5 â¡Â‹ ñFŠ¹ fun â¡Â‹ ñ£PJ™ Þ¼ˆîŠð†´œ÷¶. const int *ptr å¼ ñ£PL int ñFŠ¹‚è£ù ²†´ ptr. ñ£PèO™ ªî£ì‚è ñFŠH¼ˆî¬ô«ò ªî£ìƒA¬õˆî™ (Initialization) â¡A«ø£‹.²†´ ñ£PJ¡ ÜPMŠ¹èÀ‚è£ù â´ˆ¶‚裆´èœ: char * cptr float * fptr char Þùˆ¬î„ ²†´‹ å¼ ²†®¡ ÜPMŠ¹ float Þùˆ¶‚è£ù å¼ ²†´ void * vptr â‰îˆ îóMùˆ¬î»‹ ²†´A¡ø å¼ ²†´. å¼ ªð£¶G¬ô„ ²†´ Þšõ£Á ÜPM‚èŠð´Aø¶. W«ö»œ÷ è†ì¬÷ˆ ªî£°F¬ò‚ 裇è: float f = 7. (ptr ²†´‹ G¬ùõè ºèõKJ½œ÷ int ñFŠ¬ð ñ£ŸPò¬ñ‚è º®ò£¶) char * const cp cp â¡ð¶ å¼ ñ£PL„ ²†´. int fun(5). ܆ìõ¬í 2.

2. long double ld.h> # include <iomanip. å¼ ªêò«ôŸH unsigned int Þù‹ âQ™ Þ¡ªù£¼ ñFŠ¹‹ unsigned int Þùñ£è ñ£ŸøŠð´‹. Gó™ªðò˜ŠH Þ‰î Þùñ£Ÿøˆ¬îˆ î£ù£è«õ ªêŒAø¶. 5. 6. ÜF™ W«ö»œ÷õ£Á Þùñ£Ÿøƒèœ Gè¿‹: 1.h> void main() { clrscr(). å¼ ªêò«ôŸH long double Þù‹ âQ™ Þ¡ªù£¼ ªêò«ôŸHJ¡ ñFŠ¹‹ long double Þùñ£è ñ£ŸøŠð´‹. // demonstrating implicit type conversions // Program – 2. double d. float Þù‹ int Þùñ£è ñ£ŸøŠð†´M†ì¶.h> # include <conio. å¼ ªêò«ôŸH unsigned long int Þù‹ âQ™ Þ¡ªù£¼ ñFŠ¹‹ unsigned long int Þùñ£è ñ£ŸøŠð´‹. unsigned int ui.ÞŠ«ð£¶. àœÀ¬ø Þùñ£Ÿøˆ¶‚è£ù MFº¬øèœ: å¼ ªêòŸ°Pò£™ Þ¬í‚èŠð†´œ÷ Þó‡´ ªêò«ôŸHè¬÷»‹ å¼ ªêòŸ°P¬ò»‹ ªè£‡ì å¼ «è£¬õ¬ò â´ˆ¶‚ªè£œÀƒèœ. å¼ ªêò«ôŸH double Þù‹ âQ™ Þ¡ªù£¼ ñFŠ¹‹ double Þùñ£è ñ£ŸøŠð´‹. å¼ ªêò«ôŸH long int Þù‹ âQ™ Þ¡ªù£¼ ñFŠ¹‹ long int Þùñ£è ñ£ŸøŠð´‹. x â¡Â‹ ñ£PJ™ 7 â¡Â‹ ñFŠ¹ Þ¼‚°‹. int i. float f.2 # include <iostream. 3. å¼ ªêò«ôŸH float Þù‹ âQ™ Þ¡ªù£¼ ñFŠ¹‹ float Þùñ£è ñ£ŸøŠð´‹ 4. 47 .

cout << “\nSizeof float. getch().4 8 unsigned int . cout << “\nSizeof double. f = 2. cout <<“\nSizeof long double. 48 .2 65506 Program 2.. îóŠð´‹ å¼ «è£¬õ Ü™ô¶ îóMùˆF¡ Ü÷M¬ù (܈îóM¡ ñFŠ¬ð G¬ùõèˆF™ Þ¼ˆîˆ «î¬õŠð´‹ Þ숬î) ¬ð†´èO™ M¬ìò£èˆ .. Output Sizeof Sizeof Sizeof Sizeof Sizeof displayed by the above program: long double ..” << sizeof(d*f)<<‘\t’<<d*f. } °PŠ¹: sizeof â¡ð¶ å¼ ªêòŸ°P...unsigned long int uli.. ld = 3.17 -ä G¬ø¾ ªêŒè. cout << “\nSizeof unsigned long int .” << sizeof(f * i)<<‘\t’ << f*i... è£óí‹ â¡Â‹ ªï´‚¬èJ™ ºî™ ñFŠ¹‚°ˆ îóŠð†´œ÷ M÷‚èˆ¬îŠ «ð£ô M¬ìè¬÷ ⿶è.” << sizeof(uli* f)<<‘\t’<< uli * f.” << sizeof(ui * i) <<’\t’<< ui * i.10 9 double ...... i = -5. uli = 4..”<<sizeof(ld*d)<<‘\t’<<ld*d.8 6 float .2 -¡ Ü®Šð¬ìJ™ ܆ìõ¬í 2. ui = 6... cout << “\nSizeof unsigned int.. d = 3...4 -10 unsigned long int .

2. // int Þùˆ¬î„ ²†´‹ iptr â¡Â‹ ²†´ ñ£PJ™ float Þù ñ£PJ¡ ºèõK¬ò Þ¼ˆî ºò™õ H¬ö²†´‹ ªêŒF A¬ì‚°‹.17 Program 2. Ýù£™. // ²†´ ñ£PJ™ ªî£ì‚è ñFŠH¼ˆî™ W«ö è£μ‹ ªî£ì‚è ñFŠH¼ˆî™ H¬öò£ù‹: int * iptr.2-¡ Ü®Šð¬ìJô£ù ðJŸC ²†´ ñ£Pè¬÷ˆ ªî£ìƒA¬õˆî™ ²†´ñ£Pèœ Hø ñ£PèO¡ ºèõK¬ò Þ¼ˆF¬õ‚A¡øù. iptr = &num1. â´ˆ¶‚裆ì£è. float num1 = 10. å¼ ²†´ ñ£P â‰î Þùˆ îóM¬ù„ ²†´õîŸè£è à¼õ£‚èŠð†ì«î£. 49 . 2 ui*i ܆ìõ¬í 2. Ü«î Þù ñ£PJ¡ ºèõK¬ò«ò ãŸÁ‚ ªè£œÀ‹. num1. ²†´ ñ£Pèœ Ü¬õ ²†´‹ ñ£PJ¡ îóMùˆ«î£´ åˆF¼Šð¶ è†ì£òñ£°‹.õK¬ê ⇠1. M¬ìJ¡ ¬ð† Ü÷¾ 10 «è£¬õ ld*d è£óí‹ ld â¡Â‹ ñ£P long double â¡ð «è£¬õJL¼‰¶ ªðøŠð´‹ ñFŠ¹‹ long double Þùñ£è Þ¼‚°‹. 3. iptr = &num1. 4. int *iptr. 8 d*f —————————— ————————------ «è£¬õJL¼‰¶ ªðøŠð´‹ ñFŠ¹‹ double Þùñ£è Þ¼‚°‹. 4 4 f*l uli*f 5.5. num1 = 10.

è†ì¬÷ ܬñŠ¹: (<îó¾ Þù‹>) <ñ£P/ñFŠ¹> Ü™ô¶.7.7. b = 3. b = 3. int x. x-™ Þ¼ˆF ¬õ‚èŠð†´œ÷ ñFŠ¹ ò£¶? float x. int a = 7 . int a = 7 . è£óí‹. x-™ Þ¼ˆF ¬õ‚èŠð†´œ÷ ñFŠ¹ ò£¶? float x. x = 8% (int) 7.Þùñ£Ÿø‹ (Type Cast): å¼ ñ£PJ™ Þ¼ˆF¬õ‚èŠð†´œ÷ ñFŠH¡ îóMùˆ¬î ñ£ŸPŠ ðò¡ð´ˆ¶‹ ªêòô£‚è‹ Þùñ£Ÿø‹ â¡Á ÜPòŠð´AÁ¶ (float)7 â¡Â‹ ßÁ 7 â¡Â‹ º¿â‡ ñFŠ¬ð float Þùñ£è ñ£ŸÁAø¶. x-™ Þ¼ˆF ¬õ‚èŠð†´œ÷ ñFŠ¹ ò£¶? float x. float ñ£PL 7. x-™ Þ¼ˆF ¬õ‚èŠð†´œ÷ ñFŠ¹ ò£¶? ܆ìõ¬í 2. x = (float) 7 / 3. x =7 / 3. x-™ Þ¼ˆF ¬õ‚èŠð†´œ÷ ñFŠ¹ ò£¶? float x. «ñŸè‡ì H¬öò£ù è†ì¬÷¬ò. x = 8% 7. â¡Â‹ è†ì¬÷ ܬñŠ¹ Gó™ªðò˜ŠH¡ (compilation) «ð£¶ å¼ H¬ö²†´‹ ªêŒF¬òˆ . x = 7. <îó¾ Þù‹> (ñ£P/ñFŠ¹) Þùñ£Ÿø‹ â¡ð¶. x = 7 / 3.7 Þùñ£ŸøˆF¡ Íô‹ int ñ£PLò£è ñ£ŸøŠð†´œ÷¶.18 -ä G¬ø¾ ªêŒè.18 x-¡ ñFŠ¬ð‚ è‡ìPè 50 . âùˆ F¼ˆF ܬñ‚èô£‹. x = a/b. å¼ ñ£P Ü™ô¶ ñFŠH¡ º¡ªù£†ì£èˆ «î¬õò£ù îóMùˆ¬î‚ °PŠH´õî¡ Íô‹ Þùñ£Ÿø‹ âŒîŠð´Aø¶.0. x = a/ (float) b. % â¡Â‹ õ°eF ªêòŸ°P int îóMù ñFŠ¹èO¡ «ñ™î£¡ ªêò™ð´‹. ܆ìõ¬í 2. àœO¬í‰î Ü®Šð¬ìˆ îóMùƒèÀ‚° ñ†´«ñ àKò¶. x-™ Þ¼ˆF ¬õ‚èŠð†´œ÷ ñFŠ¹ ò£¶? float x.0 / 3.

} } c. # include <iostream. x = y + k——I. # include <iostream. v. x = 50. c) * 2 a || b && c a<b && c || d > a (c>=50) || (!flag) && (b+5 == 70) (a+b) / (a-b) (b*b) – 4 * a * c 2. iv.0. float f = 10.h> void main() { { a. iii.y. vi.h> void main() b. cout << x << f.h> void main() { int x.ðJŸC Mù£‚èœ 1. float f = 10. ii. a + pow(b.k.0.I. W›‚è£μ‹ Gó™èO™ H¬öè¬÷„ ²†®‚ 裆´è: # include <iostream. W›‚è£μ‹ «è£¬õèO™ ñFŠHì™ õK¬ê¬òˆ b˜ñ£Q‚辋: i. cout << x << f. cout << x. } 51 . x = 50.

5. W›‚è£μ‹ C++ ªñ£N‚ «è£¬õè¬÷ ñFŠH´è: a=5. (x >= y) || (!(z==y) && (z < x)) âQ™. float f âù‚ ªè£œè. Þ‰î Gó™èO¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? 4. d=1. e. f = a+b/a. d. c = d * a+b. a. c. x = a++ * d + a.3. b. int c. y = a – b++ * —b. 52 . b=3.

Gð‰î¬ù„ ªêòŸ°P¬òŠ ðò¡ð´ˆF C++ «è£¬õò£è â¿F‚ 裆´è:   x = 30 âQ™ f = 0. x = 10. ²†´ ñ£Pèœ â¡ø£™ â¡ù? 7. y = 10. z = 10  x = 9.9 Þ™¬ô«ò™ . z = 11 (ܬùˆ¶‹ º¿ â‡èœ)  x = 10. y = 10.5 Þ™¬ô«ò™ f = 5 x> = 60 âQ™ fn = 0. å¼ °P»¼ˆ îóMù ñ£PJ¡ ºèõK¬ò Þ¼ˆF ¬õ‚°‹ name â¡Â‹ ²†´ ñ£P¬ò ÜPM‚°‹ ßP¬ù â¿F‚ 裆´è. W›‚è£μ‹ Gð‰î¬ùè¬÷. y = 5. z = 2 5.7 6. 53 .

o=Commercial Taxed Dept Staff Training Institute. M¬êŠðô¬è õNò£èˆ îó¾è¬÷ àœkì£èŠ ªðø cin â¡Â‹ ªð£¼œ (C-Þ¡ âù à„êK‚è «õ‡´‹) ðò¡ð´Aø¶.03.1 àœk†´ / ªõOf†´‚ ßÁèœ îó¾è¬÷Š ªðŸÁ‚ªè£‡´ ÜõŸ¬ø„ ªêòŸð´ˆFˆ îèõô£è ªõOJ´õ«î â‰îªõ£¼ èEŠªð£P GóL¡ Þ¡Pò¬ñò£î ªêò™ð£ì£°‹.Ph:9442282076 Date: 2008. Ü®Šð¬ìò£ù àœk†´/ªõOf†´„ ªêò™ð£´èœ istream. ÜõŸÁœ å¡Á. GóL¡ Þò‚è «ïóˆF™ àœkì£èŠ ªðŸÁ‚ ªè£œõ¶.com Location: Commercial Taxes Staff Training Institute.h. ñFŠH¼ˆ¶ ßÁ Íôñ£è„ ªêŒòŠ ð´õ¶..13 11:57:14 +05'30' ð£ì‹ 3 Ü®Šð¬ì‚ ßÁèœ (Basic Statements) C++ ªñ£NJ½œ÷ Ü®Šð¬ì‚ ßÁèœ (Basic Statements) M™¬ô è¬÷Š (tokens) ðò¡ð´ˆF à¼õ£‚èŠð´A¡øù..h ÝAò î¬ôŠ¹‚ «è£Š¹èO™ õ¬óòÁ‚èŠð†´œ÷ Cô ÜPMŠ¹èO¡ Íô‹ G¬ø«õŸøŠð´A¡øù. cin «õÁõ¬è àœk†´ ÍôƒèOL¼‰¶‹ îó¾è¬÷Š 𮂰‹.h â¡Â‹ î¬ôŠ¹‚ «è£ŠH™ (Header file) îóŠ ð†´œ÷ù. C++ ªñ£N‚ ßÁ è¬÷Š ð™«õÁ õ¬èò£èŠ HK‚èô£‹: • àœk´/ ªõOf´ (Input / Output) • ÜPMŠ¹ (Declaration) • ñFŠH¼ˆî™ (Assignment) • 膴Šð£†´‚ è†ì¬ñŠ¹èœ (Control Structures) • ªêòŸÃÁ ܬöŠ¹ (Function Call) • ªð£¼O¡ ªêŒF (Object Message) • F¼ŠHòŠð™ (Return) 3. ñ£PèO™ îó¾è¬÷ Þ¼ˆF ¬õ‚è Þó‡´ õN º¬øèœ àœ÷ù. cin â¡Â‹ ªð£¼¬÷Š ðŸPò ÜPMŠ¹èœ istream. Þî¬ù º‰¬îò ð£ìˆF™ 㟪èù«õ 𮈶œ«÷£‹. c=IN. Þ¬îŠ ðŸPŠ Hø° 𣘊«ð£‹. ou=Computer Lecturer. 54 . Þ¶ Ü®Šð¬ì àœk†´ˆ ó¬ò (Standard Input Stream) à¼õ£A‚Aø¶. ostream ÝAò Þ󇮡 ð‡¹‚ ÃÁè¬÷»‹ iostream. Computer Lecturer. Þ¡ªù£¼ õNº¬ø. Gó™ ÞòƒA‚ ªè£‡®¼‚°‹«ð£¶. istream. cin â¡ð¶ C++ ªñ£NJ™ º¡õ¬óòÁ‚èŠ ð†´œ÷ å¼ ªð£¼œ (Object).Ramanathan Digitally signed by Ramanathan DN: cn=Ramanathan. ostream.h â¡Â‹ «è£Š¹ î¡ùèˆ«î ªè£‡´œ÷¶. email=ctdsti@gmail. àœk†´ˆ ó â¡ð¶. Ü®Šð¬ì àœk†´„ ê£îùñ£ù M¬êŠ ðô¬èJL¼‰¶ ªðøŠð´‹ îó¾è¬÷‚ °P‚Aø¶.

• î¬ôŠ¹‚ «è£Š¹, º¡õ¬óòÁ‚èŠð†ì ªêò™ÃÁèO¡
ܬùˆ¶ Ü®Šð¬ì ÜPMŠ¹è¬÷»‹ õ¬óò¬øè¬÷»‹
ªè£‡´œ÷¶.
• º¡-ªêòL ªïP»Áˆîˆ¬îŠ ðò¡ð´ˆF, å¼ î¬ôŠ¹‚
«è£ŠH¬ù GóL™ ެ툶‚ªè£œ÷ º®»‹.
• º¡-ªêòL ªïP»Áˆî‹ # â¡ø °P»ì¡ ªî£ìƒ°‹.
Þ¶, «î¬õò£ù ðE¬ò„ ªêŒ»ñ£Á Gó™ªðò˜ŠH‚°
à혈¶Aø¶.

• õö‚èñ£Œ å¼ º¡ªêòL ªïP»Áˆî‹ #include<iostream.h>
â¡Á ܬñ»‹. ނßÁ, iostream.h â¡Â‹ î¬ôŠ¹‚
«è£ŠH¬ù GóL™ «ê˜ˆ¶‚ ªè£œÀñ£Á Gó™ªðò˜ŠH‚°
à혈¶Aø¶. cin/cout ÝAò ªð£¼œè¬÷Š
ðò¡ð´ˆF‚ ªè£œ÷ «õ‡´ªñQ™, iostream.h â¡Â‹
«è£ŠH¬ù GóL™ ެ툶‚ªè£œ÷ «õ‡´‹.
• «õÁCô î¬ôŠ¹‚ «è£Š¹èœ: iomanip.h, stdio.h, ctype.h,
math.h, fstream.h ñŸÁ‹ Hø.
>> â¡Â‹ ªêòŸ°P îó¾ ߘŠ¹ (extraction) Ü™ô¶ îó¾ ªðÁ‹
(get from) ªêòŸ°P Ý°‹. Þ„ªêòŸ°P, îù‚° Þ승øºœ÷ óŠ
ªð£¼OL¼‰¶ (stream object) îó¾ ñFŠ¹è¬÷ â´ˆ¶, õôŠ¹øºœ÷

ñ£PJ™ Þ¼ˆF¬õ‚°‹. â´ˆ¶‚裆ì£è, W«ö»œ÷ è†ì¬÷è¬÷‚
裇è:
float temperature;
cin >> temperature;

îó¾ ߘŠ¹„ ªêòŸ°P (>>), àœk†´ˆ î£¬óŠ ªð£¼÷£ù cin-L¼‰¶
îóM¬ù ߘˆªî´ˆ¶, õôŠ¹øºœ÷ temperature â¡Â‹ ñ£PJ™ Þ¼ˆF
¬õ‚Aø¶. îó¾ ߘŠ¹„ ªêòŸ°P¬ò Ü´ˆî´ˆ¶ ܬñˆ¶, å¡Á‚°
«ñŸð†ì îó¾ ñFŠ¹è¬÷ àœk†´ˆ óJL¼‰¶ ªðŸÁ, àKò
ñ£PèO™ Þ¼ˆF¬õ‚è º®»‹. â´ˆ¶‚ 裆ì£è, temperature, humidity
ÝAò Þ¼ ñ£PèÀ‚°ˆ îó¾è¬÷ àœkì£èŠ ªðÁõ,
cin >> temperature >> humidity;

âù‚ è†ì¬÷ ܬñ‚è «õ‡´‹.
cout â¡ð¶ (C-ܾ† âù à„êK‚è «õ‡´‹) Ü®Šð¬ì ªõO
f†´ˆ ó‚ªèù º¡õ¬óòÁ‚èŠð†´œ÷ ªð£¼œ (Object) Ý°‹.
Ü®Šð¬ì ªõOf†´ˆ ó F¬ó‚ 裆Cò£èŠ ð£ŒAø¶. «õÁ ðô

55

ªõOf†´„ ê£îùƒèÀ‚°‹ ވó¬òˆ F¬êF¼Šð (redirect) º®»‹.
<< â¡Â‹ ªêòŸ°P îó¾ M´Š¹ (insertion) Ü™ô¶ îó¾  (put to)
ªêòŸ°P Ý°‹. Þ„ªêòŸ°P îù‚° õôŠð‚è‹ àœ÷ å¼ ñ£PJ¡
ñFŠ¬ð ÞìŠð‚躜÷ ªð£¼O™ Þ¼ˆF ¬õ‚°‹. â´ˆ¶‚裆ì£è,
W«ö»œ÷ è†ì¬÷è¬÷ «ï£‚°ƒèœ:
int marks = 85;
cout << marks;
cout << “\n Marks obtained is : “ << marks;
marks â¡Â‹ ñ£PJ™ «êI‚èŠð†´œ÷ ñFŠ¹ cout ªð£¼À‚°
ÜŠH ¬õ‚èŠð´‹. marks-¡ ñFŠ¹ F¬óJ™ 裆ìŠð´‹.
cout << “\n Marks obtained is : “ <<marks;

â¡Â‹ Þó‡ì£õ¶ è†ì¬÷, ªêŒF¬ò»‹ ñ£PJ¡ ñFŠ¬ð»‹
F¬ó‚° ÜŠH¬õ‚°‹. Þšõ£Á, ªõOf†´„ ªêòŸ°P¬ò Ü´ˆ
î´ˆ¶ ܬñˆ¶, å¡Á‚° «ñŸð†ì Mõóƒè¬÷ å«ó è†ì¬÷J™
ªõOJì º®»‹.
ޡ‹ Cô â´ˆ¶‚裆´èœ:
cout << “\n The sum of the variables a,b ..” << a+b;
cout << a+b << ‘\t’ << a-b << ‘\t’ << a/b;
cout << “\n The difference of numbers ….” << a-b
<< “\n The sum of two numbers …. “ << a+b;

3.2 ºî™ C++ Gó™ - C++ GóL¡ è†ì¬ñŠ¹
// My first program – Program 3.1
# include <iostream.h>//preprocessor directive
# include <conio.h>
float fact = 1; // declaration of variables
int term;
int main() // function header
{
clrscr(); // predefined function
cout << “\n This program computes factorial of a
number”;
cout << ‘\n’ << “Enter a number ...”;
cin >> term;
// looping statement
for(int x = 2; x <= term;fact *= x,x++);
cout << “\nThe factorail of the given number ..”
<< term << “ is ..” << fact;
return 0;
}

56

«ñ«ô»œ÷ Gó¬ô «ï£‚°è. å¼ C++ Gó™ Í¡Á º‚Aò HK¾
è¬÷‚ ªè£‡´œ÷¶:
• «ê˜ˆ¶‚ªè£œÀ‹ «è£Š¹èœ

ñ£Pèœ, ðòù˜ õ¬óòÁ‚°‹ ªêòŸÃÁèO¡ ÜPMŠ¹

• main() ªêòŸÃÁ.
H¬ö«ò¶I¡P Gó™ªðò˜Š¹„ ªêŒîH¡, Gó¬ô Þò‚°‹«ð£¶
main() ªêòŸÃÁ î£ù£è«õ ªêò™ð´ˆîŠð´‹. Þ‰î„ ªêòŸÃP™î£¡,
GóL¡ Hø ÃÁè¬÷»‹, Hø ªêòô£‚° è†ì¬÷è¬÷»‹ ܬö‚A¡ø
ßÁèœ Þ싪ðø «õ‡´‹.
3.3

ܬöŠ¹‚ ßÁèœ (Declaration Statements)

å¼ GóL½œ÷ ñ£Pèœ ðò¡ð´ˆîŠð´õ º¡ð£è ÜP
M‚èŠð†´ õ¬óòÁ‚èŠðì «õ‡´‹.
int *iptr;

// int Þùˆ¬î„ ²†´‹ å¼ ²†®¬ù ÜPM‚Aø¶.

iptr = new int; // int Þùˆ îó¬õ Þ¼ˆF¬õ‚è G¬ùõè Þì‹

嶂èŠð´Aø¶-âù«õ ²†´ ñ£P õ¬óòÁ‚èŠ
ð†´ M†ì¶.
*iptr = 5; // 5 â¡Â‹ ñFŠ¹ Þ¼ˆîŠð´Aø¶. G¬ùõè‹
嶂èŠð†ì Hø«è Þ¶ Gè›Aø¶.
å¼ ñ£PJ¡ ÜPMŠ¹, ñ£PJ¡ ªðò¬ó»‹ ܶ ꣘‰î îó¾
Þùˆ¬î»‹ ÜPºèŠð´ˆ¶Aø¶. â´ˆ¶‚裆ì£è, int *iptr; â¡Â‹
ÜPMŠ¬ð â´ˆ¶‚ ªè£œÀƒèœ. ‘iptr â¡ð¶ int Þùˆ¬î„ ²†´‹
å¼ ²†´ ñ£P’ âù ނßP¬ùŠ ¹K‰¶ªè£œ÷ «õ‡´‹. ܬùˆ¶„
²†´ ñ£PèÀ‹, îó¾ ñFŠ¬ð Þ¼ˆF¬õŠðKò G¬ùõè‹ å¶‚èŠ
ð´‹«ð£¶î£¡ õ¬óòÁ‚èŠð´A¡øù.
ðòù˜ õ¬óòÁ‚°‹ îóMùƒèœ, °PŠªðò˜èœ, ªêòŸÃÁ
î¬ôŠ¹èœ, ²†´ ñ£Pèœ ñŸÁ‹ Þ¬õ«ð£¡øõŸ¬ø ÜPMŠð
ÜPMŠ¹‚ ßÁèœ ðò¡ð´A¡øù. ð£ìŠHK¾ 2.3-™ ðòù˜ õ¬ó
òÁ‚°‹ îóMùƒè¬÷Š ðŸPŠ ð®ˆî¬î G¬ù¾ Øè.
å¼ ñ£P¬ò ÜPM‚°‹«ð£«î, G¬ùõè‹ å¶‚èŠð´Aø¶ âQ™,
܉î ÜPMŠ¬ð õ¬óò¬ø (definition) â¡«ø ªê£™ôô£‹. â´ˆ¶‚
裆ì£è,
int num;

â¡Â‹ ÜPMŠ¹‚ ßP¬ù «ï£‚°è. Þ‰î‚ ÃŸÁ, õ¬óò¬ø‚ ßÁ
57

â¡«ø ÃøŠð´Aø¶. è£óí‹, îóM¬ù Þ¼ˆF¬õ‚è G¬ùõè‹
嶂èŠð†´M´Aø¶. W«ö»œ÷ è†ì¬÷ˆ ªî£°F¬ò «ï£‚°ƒèœ:
int num; // æ˜ int ñ£PJ¡ ÜPMŠ¹‹ õ¬óò¬ø»‹.
num = 5; // ñFŠ¹ 5 Þ¼ˆîŠð´Aø¶.
G¬ùõè 嶂W†´‚ªèù ªõOŠð¬ìò£ù «è£K‚¬è ⶾ‹
Þ™¬ô â¡ð¬î‚ èõQˆb˜è÷£? è£óí‹ char, int, float «ð£¡ø
Ü®Šð¬ìˆ îóMùƒèO™ å¼ ñ£P¬ò ÜPM‚°‹«ð£«î G¬ùõè‹
嶂èŠð†´ M´Aø¶. 

ÜPMŠ¹‚ ßÁ å¼ ñ£PJ¡ ªðò¬ó ÜPºèŠð´ˆ¶Aø¶.
Üî¬ù å¼ °PŠH†ì îóMùˆ«î£´ ªî£ì˜¹ð´ˆ¶Aø¶. 
å¼ ñ£P‚° G¬ùõèˆF™ àKò Þì‹ å¶‚èŠð´‹«ð£¶
ܶ õ¬óòÁ‚èŠð´Aø¶. 
Cô Þù ñ£Pè¬÷ ÜPM‚°‹«ð£«î G¬ùõè‹ å¶‚èŠ
ð†´ M´Aø¶. 
²†´ Þù ñ£Pèœ ÜPM‚èŠð´‹«ð£«î õ¬óòÁ‚èŠ
ð´õF™¬ô. G¬ùõè 嶂W´ ªêŒòŠð´‹«ð£«î ܬõ
õ¬óòÁ‚èŠð´A¡øù. new ªêòŸ°P Íô‹ G¬ùõè
嶂W´ ªêŒò º®»‹.
3.4 ñFŠH¼ˆ¶ ßÁèœ (Assignment Statements)
ñFŠH¼ˆ¶ ßÁ, ñFŠH¼ˆ¶ ªêòŸ°P‚° õôŠ¹øºœ÷
å¼ «è£¬õJ¡ ñFŠ¬ð Þ승øºœ÷ ñ£PJ™ Þ¼ˆ¶Aø¶. =
â¡ð¶ ñFŠH¼ˆ¶ ªêòŸ°P Ý°‹. â´ˆ¶‚裆ì£è, ñ£PèO™
ñFŠH¼ˆ¶‹ ð™«õÁ õ¬èò£ù ßÁè¬÷‚ 裇è:
num = 5;
total = english+maths;
sum += class_marks;

ñFŠH¼ˆ¶ ªêò™ð£†®¡«ð£¶, C++ Gó™ªðò˜ŠH, õôŠ¹øºœ÷
«è£¬õJ¡ îóMùˆ¬î, Þ승øºœ÷ ñ£PJ¡ îóMùˆ¶‚° ñ£ŸP‚
ªè£œAø¶. 2.4.2. - ð£ìŠHKM™ M÷‚èŠð†ì àœÀ¬ø / ªõOŠð¬ì
Þùñ£Ÿøƒè¬÷ G¬ù¾ Øè.

58

ÜŠð®Šð†ì Å›G¬ôJ™. ªêò™ð£´ èœ å¡ø¡H¡ å¡ø£Œ õK¬êò£è G¬ø«õŸøŠð´A¡øù. ܈î¬èò î£õ½‚°‚ è£óíñ£ù Gó™ ßÁèœ è†´Šð£†´‚ ßÁèœ Ü™ô¶ 膴Š 𣆴‚ è†ì¬ñŠ¹èœ âùŠð´A¡øù.5 膴Šð£†´‚ è†ì¬÷ ܬñŠ¹èœ (Control Structures) å¼ GóL™ àœ÷ ßÁèœ è†ì£òñ£è å¡ø¡H¡ å¡ø£Œ õK¬êò£èˆî£¡ G¬ø «õŸøŠðì «õ‡´‹ â¡Aø «î¬õ Þ™¬ô. Üîù®Šð¬ìJ™ Þó†¬ìŠð¬ì Ü™ô¶ 埬øŠð¬ì â¡Â‹ ªêŒF¬ò‚ 裆´‹ ð®G¬ôè¬÷ «ï£‚°è.3. W«ö»œ÷ 𣌾Š ðìƒè¬÷ «ï£‚°è: ¸¬ö¾ êK ¸¬ö¾ îõÁ ñì‚° Gð‰î¬ù ªêò™ð£´ 2 ªêò™ð£´ 1 Gð‰î¬ù êK ªêò™ð£´ 1 îõÁ ªêò™ð£´ 3 𣌾Šðì‹-1 : «î˜‰ªî´Š¹ 1. ܶ Þó‡ì£™ õ°ð´Aøî£ â¡ð¬î„ «ê£Fˆ¶. ܶ 埬øŠð¬ì âQ™ Üî«ù£´ 1 Æ®»‹. ªêò™ð£´ 2 𣌾Šðì‹-2: ñì‚° å¼ º¿â‡¬í àœkì£èŠ ªðŸÁ. GóL¡ Cô ð°Fèœ å¼ Gð‰î¬ùJ¡ «ðK™ G¬ø«õŸøŠð´õ¶‹ à‡´. Þó†¬ìŠð¬ì âQ™ Ü«î â‡¬í»‹ ªõOJ´‹ ð®G¬ôè¬÷Š 𣌾Š ðì‹ 1-™ 裇è. å¼ º¿â‡¬í àœkì£èŠ ªðŸÁ. 𣌾‚ 膴Šð£´ GóL¡ å¼ ð°FJL¼‰¶ Þ¡ªù£¼ ð°F‚°ˆ Aø¶. 2. ÞF™ õ°‚°‹«ð£¶ eF õ¼Aø¶ âQ™ M=ODD â¡ø 59 .

while () loop switch Entry Control For(. ßø£°‹.5. ÜõŸÁœ I辋 º‚Aòñ£ù¶... b˜ñ£QŠ¹‚ ßÁèÀ‹ (Decision Making Statements). GóL¡ «õÁ ð°F‚° 强¬øˆ î£õ™ ï¬ìªðø‚ è£óíñ£Aø¶.. eF õóM™¬ô âQ™ M=EVEN â¡ø ßÁ‚°‹ ð£ŒM¡ 膴Šð£´ A¬÷ HKAø¶. Þ¡ªù£¼ b˜ñ£QŠ¹‚ ßø£ù switch.) f While () loops w «î˜‰ªî´Š¹‚ ßÁèœ (Selection Statements) å¼ GóL™ Gð‰î¬ù Ü®Šð¬ìJô£ù b˜ñ£QŠ¹ (Decision). ð™«õÁ A¬÷Š 60 .ßÁ‚°‹. GóL¡ å¼ ð°FJL¼‰¶ Þ¡ªù£¼ ð°F‚°ˆ õ‚ è£óíñ£ù Gó™ ßÁèœ è†´Šð£†´‚ è†ì¬ñŠ¹èœ âùŠð´A¡øù. 膴Šð£†´‚ è†ì¬ñŠ¹èœ Control Structures «î˜‰ªî´Š¹ Selection if . else 3. b˜ñ£QŠ¹‚ ßÁè¬÷ˆ «î˜‰ ªî´Š¹‚ ßÁèœ (Selection Statements) â¡Á‹ Ãøô£‹.. Þó‡´ ñ£ŸÁ õNèÀœ 塬øˆ «î˜‰ªî´‚A¡ø if. C++ ªñ£NJ™ b˜ñ£QŠ¹èœ ð™«õÁ º¬øèO™ «ñŸªè£œ÷Š ð´A¡øù. 膴Šð£†´‚ è†ì¬÷ ܬñŠ¹èÀœ Þó‡´ º‚Aò õ¬è Jùƒèœ.. ñì‚°‚ ßÁèÀ‹ (Looping Statements) Ý°‹.1 ñì‚° Loop Exit Control Do d . C++ ªñ£NJ™ 膴Šð£†´‚ è†ì¬ñŠ¹èœ W«ö»œ÷ ðìˆF™ 致œ÷ õ£Á 膴Šð£†´‚ ßÁè÷£™ ï¬ìº¬øŠð´ˆîŠð´A¡øù...  膴Šð£´. else. å¼ ñ£PJ¡ ñFŠ¹ Ü®Šð¬ìJ™.

Þ¶ Þ¼ õ®õƒèO™ ï¬ìº¬øŠð´ˆîŠð´Aø¶: • • if ßÁ (å¼õN) if. cin >> a. getch().2 # include <iostream.3.h> # include <conio. cout << “\nEnter a number “. if ( a%2 == 0) cout << “\nThe given number “ << a << “is even”. clrscr().3. } 61 . if ßÁ: ܬùˆ¶ˆ b˜ñ£QŠ¹‚ ßÁèO½‹ I辋 âO¬ñò£ù¶.2) if ߬ø M÷‚°Aø¶: // Program .else ßÁ (Þ¼õN) if (Gð‰î¬ù/ «è£¬õ) { if (Gð‰î¬ù/ «è£¬õ) //ªêò™ð£†´ˆ ªî£°F-1 { } else { // ªêò™ð£†´ˆ ªî£°F } //ªêò™ð£†´ˆ ªî£°F-2 } W«ö»œ÷ Gó™ (Program ..h> // Demonstrates the use and syntax of if statement void main() { int a.HK¾èÀœ å¼ A¬÷Š HKM½œ÷ è†ì¬÷ˆ ªî£°F¬ò G¬ø«õŸø õNõ°‚Aø¶.

. cin >> a. 裆ìŠð´‹..«ñŸè‡ì GóL™. ªè£´‚èŠð†ì «è£¬õ êK â¡ø£™ ñ†´«ñ “The given number 10 is even” â¡Â‹ ªêŒF 裆ìŠð´‹. cout<<“\n The given. if ( a%2 == 0) cout << “\nThe given number “ << a << “is even”.” â¡Â‹ ªêŒF.... } «ñŸè‡ì GóL™. Þ™¬ô«ò™ GóL¡ 膴Šð£´. W«ö»œ÷ Gó™ (Program 3. getch(). Þ™¬ô«ò™ else-‚° Ü´ˆ¶œ÷ ßÁ ªêò™ð´ˆîŠð´‹. clrscr(). â¡Â‹ è†ì¬÷¬ò G¬ø«õŸø£ñ™ Üî¬ù‚ è쉶 getch() ßÁ‚°ˆ î£MM´‹.h> # include <conio.h> void main() { int a.. else cout << “\nThe given number “ << a << “is odd”.3) if. 62 . ߬ø M÷‚°Aø¶: // Program – 3..3 // Demonstrates the use and syntax of if else statement # include <iostream. îóŠð†ì Gð‰î¬ù êK â¡ø£™ ñ†´«ñ “ The given. else. cout << “\nEnter a number “..

Þ™¬ô«ò™ ªêò™ð£†´ˆ ªî£°F-2 G¬ø«õŸøŠð´‹. if (1) { // ªêò™ð£†´ˆ ªî£°F-1. if (branch) { // ªêò™ð£†´ˆ ªî£°F-1.if è†ì¬÷ ܬñŠH™ Gð‰î¬ùèœ / «è£¬õèœ ªõš«õÁ ð£EJ™ îóŠð†´œ÷ â´ˆ¶‚裆´è¬÷ «ï£‚°è: branch â¡Â‹ ñ£P Gð‰î¬ùò£èŠ ðò¡ð´ˆîŠð†´œ÷¶. } else { // ªêò™ð£†´ˆ ªî£°F-2. int branch = 10 > 20. ªêò™ð£†´ˆ ªî£°F-1 G¬ø«õŸøŠð´‹. } else { // ªêò™ð£†´ˆ ªî£°F-2. if(1) â¡Á Gð‰î¬ù¬ò ܬñ‚è º®»‹.Ýè ñFŠHìŠð´ñ£J¡. } else { // ªêò™ð£†´ˆ ªî£°F-2. } å¼ «è£¬õ¬ò Gð‰î¬ùò£èˆ î󺮻‹. } ²Nò‹ (Zero) Ü™ô£î â‰î«õ£˜ â‡μ‹ êK âù â´ˆ¶‚ ªè£œ÷Šð´‹ â¡ð. if ( a % 2 ) { // ªêò™ð£†´ˆ ªî£°F-1. } 63 . «è£¬õJ¡ ñFŠð >0 .

......h> void main() { int count = 1.”. } else { cout << “\nResetting count .. if è†ì¬÷ˆ ªî£°F G¬ø«õŸøŠðì£î«ð£¶î£¡ else è†ì¬÷ˆ ªî£°F G¬ø«õŸøŠð´‹.. â¡Â‹ ªêŒF è£†ìŠ ð´‹.else.else è†ì¬÷ ܬñŠH™ if-¡ W¿œ÷ è†ì¬÷ˆ ªî£°F G¬ø«õŸøŠð´ñ£J¡.  Þ¼ ñ£ŸÁ õNèÀœ 塬øˆ «î˜‰ªî´‚°‹ if.W«ö»œ÷ Gó¬ô Þò‚Aù£™ â¡ù ªêŒF 裆ìŠð´‹ â¡ð¬î º¡ùP‰¶ ªê£™ô Þò½ñ£? // Program . è†ì¬÷ ܬñŠH™ Gð‰î¬ù Ü®Šð¬ìJ™ å¼ °PŠH†ì è†ì¬÷ˆ ªî£°F ñ†´«ñ G¬ø«õŸøŠð´‹.. } getch().3.Ý™ ªð¼‚èŠð†ì H¡Â‹ else-‚°Š Hø°œ÷ è†ì¬÷ˆ ªî£°F ã¡ ªêò™ð´ˆîŠðìM™¬ô â¡ð¬î„ ªê£™ô º®»ñ£? ÞîŸè£ù ðF™: å¼ if... if (count > 0) { cout << “\nNegating count . count *= 1.”. count *= -1. else ªî£°F G¬ø«õŸøŠ ð죶. } Þ‰î Gó¬ô Þò‚Aù£™ Negating count.4 # include <iostream. count â¡Â‹ ñFŠ¹ -1.h> # include <conio. 64 ..

Gó™ªðò˜ŠH. Gð‰î¬ù‚°Š Hø° îóŠ ð†´œ÷ ܬ󊹜O. cout << “Variable is incremented ..”. êKò£ù è†ì¬÷: if a> b cout << “True”. if ( a > b) a.. “Misplaced else” âùŠ H¬ö ²†´‹. H¬öò£ù è†ì¬÷ ܬñŠ¹ â¡ù è£óí‹? Gð‰î¬ù¬òŠ H¬ø ܬ승‚°PèÀ‚°œ îó «õ‡´‹. cout<<“\nVariable is decremented”. else a++.”. cout << “Variable is incremented .. êKò£ù è†ì¬÷ ܬñŠ¹: If ( a> b) { a--..õ.”.” Gó™ ªðò˜ŠH. 2. cout<<“\nVariable is decremented”. ⇠1. êKò£ù õ®õ‹: if (a > b). cout << “Greater. else cout <<“Lesser .” } 3. ªêò™ 𣆴ˆ ªî£°F å¡Á‚° «ñŸð†ì è†ì¬÷è¬÷‚ ªè£‡®¼ŠH¡ ªïO¾ ܬ승‚°PèÀ‚°œ îó «õ‡´‹. ܆ìõ¬í 3. if (a > b) cout << “Greater. if ßP¡ «ï£‚般î«ò «î£Ÿ 讈¶ M´‹. else cout << “Lesser . if è†ì¬÷ ܬñŠ¹ 65 . } else { a++.-..1.”. “Misplaced else” â¡Â‹ H¬ö²†´‹ ªêŒF¬òˆ .. if (a>b) cout << “True”.

Þ™¬ô«ò™ ‘B’ î¼è. ªêò™ð£´-3..2. («è£¬õ-1) («è£¬õ-2) ªêò™ð£´-1. 3.else è†ì¬÷ å¡Á‚°œ å¡ø£ŒŠ H¡ùô£è ܬñòô£‹. Þ¶«ð£¡Á H¡ùô£Œ ܬñ»‹ if. «õè‹ ñE‚° 30 A..2. “åš«õ£˜ else-‚°‹ «ñô£è.2-™ îóŠð†´œ÷ ðEè¬÷ G¬ø«õŸÁõŠ ªð£¼ˆî ñ£ù if è†ì¬÷ ܬñŠ¬ð â¿F‚ 裆´è: õ. ñFŠªð‡ 90-‚° «ñ™ Þ¼ŠH¡ ‘A’ â¡Â‹ îóG¬ô î¼è.be careful.àì¡ Þ¬í«êó£î æ˜ if Þ¼‚è «õ‡´‹” 66 .e.traffic to flow” «õè‹ ñE‚° 31-L¼‰¶ 40 A.e-‚° °¬ø¾ âQ™ if è†ì¬÷ “Accelerate .else è†ì¬÷ ܬñŠH™. W«ö»œ÷õ£Á if..” â¡ø ªêŒFè¬÷ˆ F¬óJì «õ‡´‹. «õ«ø£˜ else.܆ìõ¬í 3. if è†ì¬÷¬òŠ ðò¡ð´ˆ¶î™ H¡ùô£ù if ßÁ : å¼ if.accelerate by 10 kmph” Þ™¬ô«ò™.. ܆ìõ¬í 3.⇠ðE 1 ñFŠªð‡ 90-‚° «ñ™ Þ¼ŠH¡ ‘A’ â¡Â‹ îóG¬ô î¼è 2. õ¬ó âQ™ “Moderate . “Good. ªêò™ð£´-2.else è†ì¬÷ ܬñŠHŸ°œ Þ¡«ù£˜ if è†ì¬÷ ܬñò º®»‹.

ªõO else G¬ø«õŸøŠð´‹. «ñ«ô»œ÷ è†ì¬÷ˆ ªî£°F ªêò™ð´‹ º¬ø: • grade== ‘A’. basic ==5000 âQ™ incentive-¡ ñFŠ¹ 250 Ý°‹. basic ==5501 âQ™ incentive-¡ ñFŠ¹ 550 Ý°‹. àœ if G¬ø«õŸøŠð죶. else cout << “Try to attain Grade A”. å¼ Gð‰î¬ùJ¡ Ü®Šð¬ìJ™. Þ‚è†ì¬÷ Þšõ£Á ï¬ìº¬øŠ ð´ˆîŠð´Aø¶: 67 . âù«õ “Try to attain Grade A” â¡Â‹ ªêŒF A¬ì‚°‹. else if (grade = = ‘A’ && basic <5501) incentive = basic * 5/100. if (grade = = ‘A’ && basic > 5500) incentive = basic * 10/100. else incentive = basic * 5/100. • grade != ‘A’ âQ™. îóŠð†´œ÷ ð™«õÁ «î˜¾èO™ å¡Á‚°‚ 膴Šð£†¬ì â´ˆ¶„ ªê™½‹. «ñ«ô»œ÷ if è†ì¬÷ ܬñŠ¹. è£óí‹ ÃÁè:………… switch ßÁ: Þ¶ å¼ A¬÷HKŠ¹‚ ßø£°‹.â´ˆ¶‚裆ì£è. if (grade = = ‘A’) if (basic > 5500) incentive = basic * 10/100. else cout << “Try to attain Grade A”. W«ö»œ÷ if è†ì¬÷ ܬñŠ¹‚° Gèó£ùî£? àƒèœ ðF¬ô ‘è£óí‹ ÃÁè’ ªð†®J™ ⿶è. • grade == ‘A’.

case 3 :ªêò™ð£†´ˆ ªî£°F-3.”.h> # include <conio. break. case 2 : cout << “\nRemainder is two”. default: cout << “\nThe given number is divisible by 3”.h> void main() { int a. { case 1 : cout << “remanider 1”. cout << “\nEnter a number . default :cout << “Divisible by 3”. } 68 . cin >> a. break. default :ªêò™ð£†´ˆªî£°F-4. } } W«ö»œ÷ Gó™.3. break. break.. break. break.. switch ßP¡ ðò¡ð£†¬ì M÷‚°Aø¶: // Program . switch (remainder) { case 1 : cout << “\nRemainder is one”. case 2 :ªêò™ð£†´ˆ ªî£°F-2.5 // to demonstrate the use of switch statement # include <iostream. } getch().switch («è£¬õ) switch (remainder) { case 1 :ªêò™ð£†´ˆ ªî£°F-1. case 2 : cout << “remanider 2”. break. break. remainder = a % 3. remainder.

2 õ¼‹ ⇠âQ™.6-™ M´ð†´Š «ð£ù è†ì¬÷ ⶪõùˆ ªîKAøî£? Ý‹. break è†ì¬÷ M´ð†´œ÷¶. case 2 ÝAò Þó‡´ ªêò™ð£†´ˆ ªî£°FèÀ«ñ ã¡ ªêò™ ð´ˆîŠð†´œ÷¶ â¡ð¶ ¹KAøî£? Program-3. ²¼ƒè„ ªê£™õªîQ™. char name[] = “Shiv”. switch (rank) { case 1: cout<<‘\n’<<name<<“secured 1st rank”. • a = 5 Ü™ô¶ ܶ«ð£¡Á eF “Remainder is two” âù‚ 裆´‹.5 ñŸÁ‹ Program.h> # include <conio. } Þ‰î GóL¡ ªõOf´ Þšõ£Á Þ¼‚°‹: Shiv secured 1st rank Shiv secured 2nd rank case 1.3.h> void main() { int rank = 1. • a = 3 Ü™ô¶ ܶ«ð£¡Á 3-Ý™ õ°ð´‹ ⇠âQ™.3. } getch(). • a = 4 Ü™ô¶ ܶ«ð£¡Á eF “Remainder is one” âù‚ 裆´‹ 1 õ¼‹ ⇠âQ™. ÞFL¼‰¶ ÜPòõ¼õ¶ â¡ù? 69 .3.6 ÝAò Þ¼ Gó™èO½‹ àœ÷ ªêò™ð£†´ˆ ªî£°Fè¬÷ åŠH†´Š 𣼃èœ. W«ö»œ÷ GóL¡ ªõOf´ â¡ùõ£è Þ¼‚°‹ â¡Á áA‚è º®Aøî£? // Program . “The given number is divisable by 3” âù‚ 裆´‹. ªè£´‚èŠð†ì ⇠͡ø£™ õ°ð´‹ â‡í£ âùŠ 𣘈¶ ÜèŸð ªêŒF¬òˆ F¬óJ™ 裆´‹.6 // to demonstrate the use of switch statement # include <iostream. Program.«ñŸè‡ì Gó™. case 2: cout<<‘\n’<<name<<“secured 2nd rank”.

enum. int) Þù‹ê£˜‰î ñ£PLò£è Þ¼‚è «õ‡´‹. Üî¡ ªêò™ð£†´ˆ ªî£°F G¬ø«õŸøŠ ð´Aø¶. case 2. Gð‰î¬ùJ¡ Ü®Šð¬ìJ™ 膴Šð£´ î£M„ ªê¡Á GŸ°‹ case-™ ªî£ìƒA Ü´ˆî´ˆ¶œ÷ case-èO¡ ªêò™ð£†´ˆ ªî£°Fèœ õK¬êò£è G¬ø«õŸøŠð´‹. Þ𣼜. ÜF™ break è†ì¬÷ Þ™ô£î è£óíˆî£™ case 2-¡ ªêò™ 𣆴ˆ ªî£°F»‹ õK¬êò£è G¬ø«õŸøŠð´Aø¶. } “switch selection expression must be of integral type” âù Gó™ float value.5. case “Rama” : cout << ‘\n’ << name << “ secured 2nd rank”. char name[ ] = “Shiv”. è£óí‹ è£‡è: 1. Þ™¬ô«ò™. ܈ªî£°FJ¡ ÞÁFJ™ break è†ì¬÷¬ò„ «ê˜‚è «õ‡´‹. switch (name) { case “Shiv” : cout << ‘\n’ << name << “secured 1st rank”. } switch() ßP™ Þ싪ðÁ‹ «è£¬õ float Þùñ£è ªðò˜ŠH H¬ö²†´‹.6) 膴Šð£´ case 1-‚° â´ˆ¶„ ªê™ôŠð´Aø¶. «ñŸè‡ì â´ˆ¶‚裆®™ (Program . switch (value) { case 1. Þ¼Šð H¬öò£Aø¶.5 : cout << ‘\n’ << value – 0. º¿â‡(char.1.switch-™ Þì‹ ªðÁ‹ «è£¬õJ¡ ñFŠ¹.9 : cout << ‘\n’ << value + 0.  °PŠH†ì case-¡ ªêò™ð£†´ˆ ªî£°F G¬ø«õŸøŠð†ì¾ì¡ switch ߬øM†´ ªõO«òø. W«ö è£μ‹ swich è†ì¬÷ ܬñŠ¹èœ H¬öò£ù¬õ. 70 .3. 2.嚪õ£¼ ªêò™ð£†´ˆ ªî£°FJ½‹ ÞÁFJ™ break è†ì¬÷ Þ싪ðø «õ‡´‹.

break.3. F¼‹ðˆ F¼‹ð G¬ø«õŸøŠðì «õ‡®ò è†ì¬÷ˆ ªî£°FJ¡ ªî£ì‚舶‚° â´ˆ¶„ ªê™ôŠð´‹. goto loop_start. case-™ å«óªò£¼ switch (rank) { case 1 to 2 : cout << ‘\n’ << “Best rank”. 71 . ñì‚°èœ (Loops) ñì‚°èœ. loop_start: if (i < 6) { cout << i <<‘\t’.h> è†ì¬÷ˆ ªî£°F¬ò G¬ø«õŸÁõŠ ðK«ê£F‚è «õ‡®ò Gð‰î¬ù void main() { int i = 1.3. } º¿â‡ ñFŠ¹ ñ†´«ñ Þ싪ðø «õ‡´‹. case 1 to 2 â¡ð¶ ãŸèˆ îè£î ßø£°‹. Þ‰î Gó™ ð°F¬ò Þšõ£Á â¿î«õ‡´‹. W«ö»œ÷ Program . case 3 to 4 : cout << ‘\n’ << “Good rank”. break.5. i = i + 1. â´ˆ¶‚裆ì£è.7 # include <iostream.h> # include <conio. } 3.2. switch (rank) {case 1 : case 2 : cout << “Best rank”.7-ä «ï£‚°è: // Program .3. case 3 : case 4 : cout << “Good rank”. å¼ °PŠH†ì ªêò™ð£†´ˆ ªî£°F¬ò å¡Á‚° «ñŸð†ì ñFŠ¹èÀ‚°Š ðò¡ð´ˆî «õ‡´ªñQ™. } } F¼‹ðˆ F¼‹ð G¬ø«õŸøŠðì «õ‡®ò è†ì¬÷ˆ ªî£°F GóL¡ 膴Šð£´. å¼ è†ì¬÷ˆ ªî£°F¬ò °PŠH†ì îì¬õèœ F¼‹ðˆ F¼‹ð G¬ø«õŸÁA¡øù. break.

i = i + 1. 3. } 72 .) G¬ø«õŸøŠð´Aø¶. loop_start: if (i < 6) { cout << i << ‘\t’. Üîù®Šð¬ìJ™. Program. Gð‰î¬ù êK âQ™ ªêò™ð£†´ˆ ªî£°F (cout<<i. ñì‚A¡ àìŸ ð°F‚° e‡´‹ e‡´‹ F¼ŠHMìŠð†´. } //Program . i = i + 1. loop_start: { cout << i << ‘\t’. 膴Šð£†´‚ ßÁ Gð‰î¬ù¬ò„ êK𣘂Aø¶. Ýè. GóL¡ 膴Šð£´. 膴Šð£†´‚ ßÁ â¡Â‹ Þ¼ ð°Fè¬÷‚ ªè£‡´œ÷¶. i < 6 â¡Â‹ åŠd†´‚ «è£¬õ ðK«ê£F‚èŠð´A¡ø¶. } cout << i. àìŸð°F. 2. è£óí‹.7 B void main() { int i = 6. i â¡Â‹ ñ£P ÜPM‚èŠð†´ ªî£ì‚è ñFŠH¼ˆîŠð´Aø¶. if (i < 6) goto loop_start.i=1. ÞŠ«ð£¶ W«ö»œ÷ Gó™è¬÷ «ï£‚°ƒèœ: //Program . goto loop_start. 膴Šð£†´ ñ£P âù‚ °PŠHìŠð´Aø¶. } cout << i. i â¡ø ñ£P. 1 ºî™ 5 õ¬óJô£ù â‡è¬÷ˆ F¬óJ™ 裆´‹. if ßP¡ W› îóŠð†´œ÷ ªêò™ð£†´ˆ ªî£°F 5 º¬ø G¬ø«õŸøŠð†´.«ñ«ô è£μ‹ Gó¬ô Þò‚Aù£™.3.3. ñì‚°ˆ ªî£°F. è†ì¬÷ˆ ªî£°F F¼‹ðˆ F¼‹ð G¬ø«õŸøŠðì i-¡ ñFŠ«ð è£óí ñ£è ܬñA¡ø¶.3. F¼‹ðˆ F¼‹ð G¬ø «õŸøŠð´Aø¶.7 Þšõ£Á ªêò™ð´Aø¶: 1.7 A void main() { int i = 6. åŠd†´‚ «è£¬õJ¡ Gð‰î¬ù Ü®Šð¬ìJ™ å¼ è†ì¬÷ˆ ªî£°F F¼‹ðˆ F¼‹ð„ ªêò™ð´ˆîŠð´Aø¶. GóL¡ 膴Šð£´ e‡´‹ loop_start â¡Â‹ Þ숶‚° â´ˆ¶„ ªê™ôŠð´Aø¶ (goto loop_start).

) ÝAò è†ì¬÷èÀ‚°Š Hø° Gð‰î¬ù Þ싪ðŸÁœ÷¶.7B) âù Þ¼õ¬èò£èŠ HK‚èô£‹.7A). i=i+1. Þ‰î GóL™. Gð‰î¬ù ñ£PJ¡ ñFŠ¹ I°‚èŠð´Aø¶. æ˜ åŠd†´‚ «è£¬õJ™ ðK«ê£F‚èŠ ð´Aø¶. 7 âù‚裆´‹. âù«õ Þ‚è†ì¬÷èœ å¼º¬ø G¬ø«õŸøŠð†´ M´‹.3. ¸¬ö¾-«ê£FŠ¹ ñì‚° (Program3. (cout<<i. 3.Program-3. Þšõ£Á ï¬ìªðÁAø¶: 1. Gð‰î¬ù ñ£PJ™ ªî£ì‚è ñFŠ¹ Þ¼ˆîŠð´Aø¶. ªð£¶õ£è å¼ ñì‚A¡ ªêòô£‚è‹. ÞFL¼‰¶  ÜPõ¶ â¡ù?  ñì‚A™ àìŸð°FJ¡ ÞÁFJ™ Gð‰î¬ù îóŠð´ñ£J¡. Gð‰î¬ù ñ£P. Ü™ô¶ ñ사è M†´ ªõO«òÁ‹. ÞŠ«ð£¶ i-¡ ñFŠ¹ 7 â¡ð GóL¡ 膴Šð£´ loop_start Þ¼‚°I숶‚° â´ˆ¶„ ªê™ôŠðìM™¬ô. Í¡Á õ¬èò£ù ñì‚°èœ àœ÷ù: 1) for() ñì‚° 2) while() ñì‚° 3) do. ªõO«ø™-«ê£FŠ¹ ñì‚° (Program . ñì‚°è¬÷. àìŸð°FJ¡ ªî£ì‚舶‚° â´ˆ¶„ ªê™ôŠð´‹. 6 âùˆ F¬óJ™ 裆´‹. 4.«ñŸè‡ì Gó™èO¡ ªõOf´ â¡ùõ£è Þ¼‚°ªñ¡Á G¬ù‚ Al˜èœ? Program-3.  Gð‰î¬ù Þ싪ðÁ‹ Þìˆ¬îŠ ªð£Áˆ¶.while() ñì‚° 73 . C++ ªñ£NJ™.. è†ì¬÷ˆ ªî£°F å¼ º¬ø«ò‹ G¬ø«õŸøŠð†´M´‹. ñì‚A¡ àìŸð°F 强¬ø G¬ø«õŸøŠð´Aø¶.7A. Üî¡Hø° Gð‰î¬ù êK𣘂èŠð´Aø¶. åŠd†´‚ «è£¬õJ¡ ñFŠ¹ Ü®Šð¬ìJ™ 膴Š ð£´. 2.7B.

int num = 2.8 GóL¡ Ü®Šð¬ìJ™ W«ö»œ÷ Mù£‚èÀ‚° M¬ì î¼è: Ü) ܬìò£÷‹ 裇è: 1.. ðò¡ð´ˆîŠð†´œ÷ 膴Šð£†´ ñ£P 2.. do { cout << num * num << ‘\t’. }while (num < 6).h> # include <conio. } while <(Gð‰î¬ù)> W«ö»œ÷ Gó¬ô «ï£‚°ƒèœ: // Program . } Program -3.h> // to print the square of numbers // between 2 to 5 void main() { clrscr(). ñì‚A¡ àì™ð°FJ½œ÷ è†ì¬÷èœ 3. num += 1. ðK«ê£FŠ¹‚ «è£¬õ Ý) ñì‚°‚ è†ì¬÷èœ âˆî¬ù º¬ø G¬ø«õŸøŠð´‹? Þ) GóL¡ ªõOf´ â¡ù? ß) Þ¶ â¡ù õ¬èò£ù ñì‚°? 74 .do. getch().while() ñì‚°: Þî¡ è†ì¬÷ ܬñŠ¹ Þšõ£Á Þ¼‚°‹: do { ªêò™ð£†´ˆ ªî£°F.8 # include <iostream.3.

cout << ctr. 75 . do { int ctr = 1.«ê£FŠ¹ ñì‚° âùŠð´‹. 3. Gð‰î¬ù «ê£F‚èŠð´Aø¶. }while(ctr). 膴Šð£†´ ñ£PJ¡ ñFŠ¹ 1 I°‚èŠð´Aø¶. sum = sum + ctr. sum = 0. num-¡ Þó‡ì£‹ Ü´‚° ñFŠ¬ðˆ F¬óJ™ 裆´Aø¶. ñì‚A¡ àìŸð°F‚ è†ì¬÷ èÀœ ÞÁFò£è Þ싪ðŸÁœ÷¶. è£óí‹. Gð‰î¬ù‚ «è£¬õ¬òŠ ð™«õÁ õ¬èJ™ ܬñ‚è º®»‹. 膴Šð£†´ ñ£P num 2.2. ñì‚° º®¾ ªðÁAø¶. «ê£î¬ù º®M¡ Ü®Šð¬ìJ™ 膴Šð£´ ð®G¬ô-2‚° ñ£ŸøŠð´Aø¶.M¬ìèœ: Ü) 1. ctr = ctr + 2. sum = 0. sum = sum + ctr. num += 1. â´ˆ¶‚裆´èœ 裇è: int ctr = 5. ñì‚A¡ àì™ð°F‚ è†ì¬÷èœ: cout<<num*num<<‘\t’. }while(check).. do { cout << ctr. Gð‰î¬ù‚ «è£¬õ. (num<6) â¡ð¶ ðK«ê£FŠ¹‚ «è£¬õ Ý) ° º¬ø Þ) 4 9 16 25 ß) ªõO«òø™-«ê£FŠ¹ ñì‚° Þ‰î ñì‚A¡ ªêò™ð£†´Š ð®G¬ôè¬÷‚ 裇è: 1. ñì‚A™ ¸¬öAø¶. 2. 4. 3. check = 1.while(Gð‰î¬ù) â¡Â‹ ñì‚° ªõO«òø™ . ctr = ctr . check = (ctr < 11). 5. do.

ctr = ctr . W«ö»œ÷ Gó™èO¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? Snippet A-J™ i-¡ ñFŠ¹ -32768 Ý°‹õ¬ó ñì‚° G¬ø«õŸøŠð´‹. Snippet B-J™ choice-¡ ñFŠ¹ ⊠«ð£¶«ñ 1 â¡ð Gð‰î¬ù ⊫𣶫ñ êK â¡ø£A M´Aø¶. }while(ctr >= 1). Þó‡´ ñì‚°èO½‹ îóŠð†´œ÷ Gð‰î¬ùèœ âŠ«ð£¶«ñ êKò£è«õ Þ¼‚°‹. Snippet A-J™ i-¡ ñFŠ¹ ⊫𣶫ñ 10-ä Mì‚ °¬øõ£è«õ Þ¼‚°‹. Snippet A.2. å¼ è†ìˆF™ Gð‰î¬ù ‘îõÁ’ â¡Á Ý°ñ£Á êKò£ù Gð‰î¬ù¬ò ܬñŠð¶ I辋 º‚Aòñ£°‹.int ctr = 5. 76 . sum = sum + ctr. ñì‚A™ îóŠð´‹ «ê£FŠ¹‚ «è£¬õ «ò£´ ªî£ì˜¹¬ìò 膴Šð£†´ ñ£PJ¡ ñFŠ¬ð I°ˆ¶/¹¶ŠHˆ¶ Þ‰î G¬ô¬ò â†ì «õ‡´‹. Snippet B ÝAò Þó‡´ Gó™èO½‹ àœ÷ ñì‚°èœ õó‹Hô£ ñì‚°è÷£°‹.c=1.sum = 0. do { cout << ctr.

F¬óJ™ 裆ìŠð´Aø¶.while() ñì‚A™ M÷‚èŠð†ì Ü«î Gó¬ô while() ñì‚° ðò¡ð´ˆF e‡´‹ ⿶«õ£‹. M¬ì ‘êK’ â¡ø£™ ñ†´«ñ 膴Šð£´ ð®G¬ô-3‚° ñ£ŸøŠð´Aø¶. GóL¡ 膴Šð£´ ð®G¬ô-2‚° ñ£ŸøŠð´Aø¶. num â¡Â‹ ñ£PJ™ Þ¼ˆîŠð†ì ñFŠH¡ Þó‡ì£‹ Ü´‚°. 6.9 # include <iostream. 5.3. 4. num<2 â¡Â‹ «ê£FŠ¹‚ «è£¬õ ñFŠHìŠð†´.h> # include <conio.while() ñì‚°: Þ¶ ¸¬ö¾-«ê£FŠ¹ ñì‚° âùŠð´‹. Þî¡ è†ì¬÷ ܬñŠ¹: while <(condition)> { ªêò™ð£†´ˆ ªî£°F. 77 . } while() ßP™ àœ÷ «ê£FŠ¹‚ «è£¬õ ‘êK’ â¡Â‹ M¬ì¬òˆ î‰î£™ ñ†´«ñ ñì‚A¡ àìŸð°FJ½œ÷ è†ì¬÷èœ G¬ø«õŸøŠ ð´‹. while (num < 6) { cout << num * num << ‘\t’. 2.. num += 1. num â¡Â‹ 膴Šð£†´ ñ£PJ™ 2 â¡Â‹ ªî£ì‚è ñFŠ¹ Þ¼ˆîŠð´Aø¶. } getch(). 3. do. (Program-3. «ñŸè‡ì ñì‚° Þšõ£Á ªêò™ð´‹: 1. ñì‚° º®¾ ªðÁAø¶.h> // to print the square of numbers // between 2 to 5 void main() { clrscr(). // Program . «ê£FŠ¹‚ «è£¬õJ¡ ñFŠ¹ ‘îõÁ’ âù Ý°‹«ð£¶ ñì‚° º®¾‚° õ¼‹. num ñ£PJ¡ ñFŠ¹ å¡Á I°‚èŠð´Aø¶. } ñì‚A¡ àìŸð°FJ¡ ªî£ì‚èˆF™ «ê£FŠ¹‚ «è£¬õ Üî£õ¶ Gð‰î¬ù îóŠð†´œ÷¶.9). int num = 2.

h> void main() { int x = 3. ctr <=y Ý) Í¡Á îì¬õèœ Þ) 81 ß) ‘¸¬ö¾ . } cout << “x to the power of y is : “ << res. getch(). while(ctr <= y) { res *= x. 3. } Ü) 1. ñì‚A¡ àìŸð°F‚ è†ì¬÷èœ â¬õ? 3. res *= x. ðK«ê£FŠ¹‚ «è£¬õ â¶? Ý) ñì‚° âˆî¬ùº¬ø G¬ø«õŸøŠð´Aø¶? Þ) Þ‰î GóL¡ ªõOŠð£´ ò£¶? ß) ÞF™ ðò¡ð´ˆîŠð†´œ÷¶ â‰î õ¬èò£ù ñì‚°? M¬ìèœ: Ü) 1. ctr += 1. //Program-3. Þ‰î GóL™ ðò¡ð´ˆîŠð†´œ÷ 膴Šð£†´ ñ£P â¶? 2.res = x.«ñŸè‡ì Gó™ Program. ctr = 2.3.h> # include <conio. 膴Šð£†´ ñ£P ctr 2. y = 4. ct +=1.«ê£FŠ¹’ Ü™ô¶ ‘¸¬ö¾‚ 膴Šð£†´ ñì‚°’ õ¬è 78 .¡ Ü®Šð¬ìJ™ W›‚è£μ‹ Mù£‚ èÀ‚° M¬ì ÜO‚辋.10 # include <iostream.10.

getch(). Gó™èœ êKò£è„ ªêò™ð´ñ£Á H¬öè¬÷ˆ F¼ˆ¶è: //Program .W«ö»œ÷ Gó™ Program-3.12 A # include <iostream. n âùˆ îóŠð†´œ÷î£è‚ ªè£œè: // Program . int counter = 0.” << counter << “ times”. char choice = ‘y’.h> void main() { clrscr().h> # include <conio. ÞõŸP½œ÷ H¬öè¬÷‚ è‡ìPè. y.h> # include <conio.12 A //Program ..h> //to print numbers between 5&10 void main() { int start = 5. } # include <iostream.3. } cout << “\The loop is executed . end = 10.”. } 79 .11-¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? Þ‰î G󽂰 àœkì£è y.. getch(). counter = counter + 1. end = 10.h> //to print numbers between 5&10 void main() { int start = 5. y. getch(). while (start >= end) cout << start++.h> # include <conio.11 # include <iostream. cin >> choice. while (start <= end) cout << start++. } W«ö»œ÷ °ÁGó™èœ H¬öò£ù¬õ. while (choice == ‘y’) { cout << “Continue <y/n> .. y.

I°Š¹) { ªêò™ð£†´ˆ ªî£°F. } for(. 2.h> # include <conio. int start = 1. while (1) cout << start++.h> // to print numbers between 1 & 5 void main() { clrscr().h> // to print numbers between 10&5 void main() { clrscr(). Gð‰î¬ù ‘êK’ âQ™ ñì‚A¡ àìŸð°F ªêò™ð´ˆîŠð´‹. } } //Program – 14 A # include <iostream. int start = 1. getch(). 80 . Gð‰î¬ù ðK«ê£F‚èŠð´‹. } for() ñì‚°: Þ¶ å¼ ¸¬ö¾‚ 膴Šð£†´ ñì‚°. int start = 5. getch(). getch().) ñì‚°Š ªð£¶õ£è Þšõ£Á ªêò™ð´‹: 1.h> # include <conio. GóL¡ 膴Šð£´ ºî¡ºîL™ ñì‚AQ™ ¸¬ö»‹«ð£¶. «ê£FŠ¹ Gð‰î¬ù. //Program – 13 B # include <iostream. getch().end = 10.//Program – 13 A # include <iostream.h> // to print numbers between 10&5 void main() { clrscr().h> # include <conio.h> # include <conio. while (start <= end) cout << start--. Þî¡ è£óíñ£è«õ Þ‰î ñì‚° ‘¸¬ö¾‚ 膴Šð£†´ ñì‚°’ âùŠð´Aø¶. å¼ ªêò™ð£†¬ì‚ °PŠH†ì îì¬õèœ G¬ø «õŸÁõ Þ¶ ðò¡ð´Aø¶. int start = 5. } //Program – 14 B # include <iostream.end = 10. Þî¡ è†ì¬÷ ܬñŠ¹: for (ªî£ì‚è ñFŠ¹.. while (Start <=5) cout << start++. while (start <= end) cout << end--.h> // to print numbers between 1 & 5 void main() { clrscr(). 膴Šð£†´ ñ£PJ™ ªî£ì‚è ñFŠ¹ Þ¼ˆîŠð´‹.

81 .” <<fact.. å«ó 强¬ø  ªêò™ð´ˆîŠð´‹.3. Gð‰î¬ù ‘îõÁ’ âù Ý°‹«ð£¶ ñì‚° º®¾‚° õ¼‹. Gð‰î¬ù ðK«ê£F‚èŠð´õ º¡ð£è‚ 膴Šð£†´ ñ£PJ¡ ñFŠ¹ I°‚èŠð´‹.h> # include <conio.) ñì‚A¡ ªêò™ð£†¬ì M÷‚°‹: //Program .h> void main() { int i. i++) fact *= i. e‡´‹ Gð‰î¬ù ðK«ê£F‚èŠð´‹. cout << “\nThe factorial of the number is . 4. for(i = 1.. } for(i = 1. W«ö»œ÷ Gó™ for(. ñì‚A¡ àìŸð°F e‡´‹ G¬ø«õŸøŠð´õ º¡ð£è‚ 膴Šð£†´ ñ£PJ¡ ñFŠ¹ I°‚èŠð†´. i < 6. fact = 1. i++) I°ˆî™ (ºî™ ð°F) ðK«ê£FŠ¹ Gð‰î¬ù (2-Ý‹ ð°F) 膴Šð£†´ ñ£PJ™ ªî£ì‚è ñFŠH¼ˆî™ (3-Ý‹ ð°F)    膴Šð£†´ ñ£PJ™ ªî£ì‚è ñFŠH¼ˆî™. ñì‚A¡ àìŸð°F 嚪õ£¼º¬ø ªêò™ ð´ˆîŠð´õ º¡ð£è¾‹ Gð‰î¬ù ðK«ê£F‚èŠð´‹. ñì‚A¡ àìŸð°F ºî¡ºîL™ ªêò™ ð´ˆîŠð´õ º¡ð£è.15 # include <iostream. i < 6.3.

for (int i = 1.h> ªõOf´: 10 void main() { int ctr = 10. ctr >= 6. getch().. .W«ö»œ÷ Gó™è¬÷ «ï£‚°è.j < 3. å«óªò£¼ Gð‰î¬ù (õôŠ ¹ø‹ àœ÷¶) ñ†´«ñ êKð£˜‚èŠ ð´‹. 1 2 3 4 5 6 7 // j< 8 õ¬ó ñì‚°‚ ªêò™ð´‹.j<3.h> # include <conio. // Program – 3. 120 for() ßP™ ªî£ì‚è ñFŠH¼ˆî™ ñŸÁ‹ I°Š¹Š ð°FJ™ å¡Á‚° «ñŸð†ì ßÁèœ Þ싪ðŸÁœ÷ù.h> void main() { clrscr().” << fact. i < 8.i < 8.fact =1. W«ö»œ÷ ¹«ó£Aó£‹ ð°FJ¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? void main() { for (int i = 1.. å¡Á‚° «ñŸð†ì Gð‰î¬ùèœ && Ü™ô¶ || ªêòŸ°P»ì¡ îóŠðì «õ‡´‹. j = 0 . } 9 8 7 6 // Program – 3.17 # include <iostream. ctr—) cout << ctr << ‘\n’. for( ) ñì‚A½œ÷ 嚪õ£¼ ð°F»‹ ðô ßÁè¬÷Š ªðŸP¼‚è º®»‹.i++). } ªõOf´: The factorial. cout <<“\nThe factorial .i++.j++) cout << i << ‘\t’.i<6. j = 0 . 裟¹œO„ ªêòŸ°P ªêò™ð´‹ F¬êºè‹ G¬ù¾ Øè. } 82 ªõOf´ Þšõ£Á Þ¼‚°‹: 1 2 3 // j < 3 õ¬ó ñì‚° ªêò™ð´‹. ÞõŸP¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? â¿F‚ 裆´è.h> # include <conio. ܬõ 裟¹œOò£™ HK‚èŠð†®¼‚è «õ‡´‹.i++.j++) cout << I << ‘\t’.16 # include <iostream. for(int i=2. èõQˆb˜è÷£? è†ì¬÷ ܬñŠH¡ð®»‹ î¼‚è º¬øJ½‹ «ñŸè‡ì ßÁ êKò£ù«î.fact*=i. for(.

int sum =0.18 # include <iostream. for(.ctr <= 5. Þî¡ ªõOf´ 5 âù‚ 裆´‹. for (ctr =1. âù«õ. ctr = ctr + 1. cin >> ch.h> void main() { clrscr(). ctr = 1. sum += ctr. } ªõOf´ Þšõ£Á Þ¼‚°‹: sum : 15 ªî£ì‚è ñFŠH¼ˆî™ ñŸÁ‹ I°Š¹‚ ßÁèœ for() ܬñŠ¹‚°œ îóŠðìM™¬ô â¡ð¬î‚ èõQˆb˜è÷£? Continue Continue Continue Continue sum:10 Choice : <y/n> <y/n> <y/n> <y/n> ? ? ? ? y y y n n ÞF™ for() ñì‚° âˆî¬ù îì¬õèœ G¬ø«õŸøŠðì «õ‡´‹ â¡ð¶ Þò‚è«ïóˆ F™ b˜ñ£Q‚èŠð´õ¬î‚ èõQˆb˜è÷£? W«ö»œ÷ Gó™ ð°FJ™ è£íŠð´‹ H¬ö ò£¶? int ctr. ctr++.ch == ‘y’.) { sum += ctr. ctr++).h> # include <conio. } // Program – 3.19 # include <iostream. char ch =’y’. sum = 0. cout << sum. int sum =0. ñì‚A¡ àìŸð°Fò£è‚ è¼îŠðìM™¬ô. cout << “\nChoice : “ << ch.h> void main() { clrscr(). getch(). è£óí‹ â¡ùªõ¡Á ¹KAøî£? for() ߬ø Ü´ˆ¶ ܬ󊹜O ÞìŠð†´œ÷¶. 83 . sum + = ctr â¡Â‹ è†ì¬÷. cout <<“\nContinue <y/n> ? ”. for(.h> # include <conio.// Program – 3. } cout << “\nSum :” << sum.) { sum += ctr. } cout << “\nSum :” << sum. getch(). ctr = 1. ctr <5.

3.h> 膴Šð£´ for() ñì‚A¡ I°Š¹Š ð°F‚° â´ˆ¶„ ªê™ôŠð´‹. } cout << “\nSum of evennos.3. for(.sum = 0.5. getch(). âù«õ ªõOf´ ⊫𣶋 1 Ýè«õ Þ¼‚°‹. //Program– 3. 20 # include <iostream.W«ö»œ÷ Gó™ð°FèO¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? for(it ctr =1.h> # include <conio. ñì‚° ‘º®Mô£ ñì‚°’ ÝAM´‹. continue å¼ ñì‚A¡ àìŸð°FJ™ Þ싪ðÁ‹ continue è†ì¬÷. ctr++) cout << ctr. ñì‚°.. } cout <<i. continue. àìŸð°FJ™ 膴Šð£†´ ñ£PJ¡ ñFŠ¹ e‡´‹ e‡´‹ 1 ÝA M´Aø¶. } 84 . . ñì‚A¡ àìŸð°FJ™ continue è†ì¬÷‚°ŠH¡ Þ싪ðÁ‹ è†ì¬÷èœ G¬ø«õŸøŠðì£.i++) { if( i % 2 == 0) { sum += i. void main() { int i = 1.”<<sum. +32767 ÝAòõŸÁ‚° Þ¬ì«òò£ù ñFŠ¹è¬÷ˆ ªî£ì˜‰¶ 裆®‚ ªè£‡®¼‚°‹. ñì‚A¬ù Ü´ˆî ²öŸC‚° Þ†´„ªê™½‹. Gð‰î¬ù‚ «è£¬õ Þ™ô£î è £ ó í ˆ î £ ™ int Þ ù ˆ F ¡ õó‹ªð™¬ô -32768.i<10. ‘º®Mô£ ñì‚°’ ÝAM´‹.

x++) { if (a[x] == search_item) { cout << “\nItem found at position .5.21-ä «ï£‚°ƒèœ: //Program .h> # include <conio.21 # include <iostream.6. } } cout << ‘\n’ << “value of index position is .3.” << x.3..8.” << x. int search_item = 7.h> void main() { clrscr(). ñì‚A¡ ªêò™ð£´ GÁˆîŠð´Aø¶.4. x<9.2. } 85 .9}.. break ðK«ê£FŠ¹ Gð‰î¬ù ‘îõÁ’ Ý°‹«ð£¶. getch().7. Ýù£™ Cô Å›G¬ôèO™.ð™«õÁ ñì‚°èO™ continue ªêò™ð´‹ Mîˆ¬î‚ W«ö 裇è: 3. for(int x=0. int a[] = {1. Program .4.3.5. ðK«ê£FŠ¹ Gð‰î¬ù â¡ùõ£è Þ¼‰î£½‹ °PŠH†ì î¼íˆF™ ñì‚A¬ù º®ˆ¶¬õ‚è «ïóô£‹. break. â´ˆ¶‚裆ì£è.

22 # include <iostream. GóL¡ 膴Šð£†¬ì ñì‚°‚° ªõO«ò â´ˆ¶„ ªê™Aø¶. x -¡ ñFŠ¹ 6 -Ýè Þ¼‚°‹ « ð £ ¶ .. W«ö»œ÷ Gó™ Program.22-ä «ï£‚°è. H¡ùô£ù ñì‚°èœ (Nested Loops) å¼ ñìƒA¡ àìŸð°FJ™ Þ¡ªù£¼ ñì‚° H¡ùô£Œ ܬñòô£‹. break è†ì¬÷ ñì‚A¬ù ºP‚Aø¶.3. } 86 Þî¡ ªõOf´: * * * * * * .Þî¡ ªõOf´ Þšõ£Á ܬñ»‹: Item found at position .3. 6 Value of index position is.6  break è†ì¬÷.  break è†ì¬÷ ܶ Þ싪ðÁ‹ ñì‚A¬ùM†´ ªõO«òø„ ªêŒ»‹. } cout << ‘\n’. for(int i = 1. // nesting of loops – Program.h> void main() { clrscr().. i <= 3. while(j <= i) { cout << “* “.  break è†ì¬÷ ܶ Þ싪ðÁ‹ ñì‚A¬ùM†´ î£õ„ ªêŒ»‹. } getch(). i++) { int j = 1.h> # include <conio. j++.

h> # include <conio.ñì‚°èO¡ ªêò™ð£´ Þšõ£ø£è ܬñAø¶: H¡ù™ ñì‚°èO¡ ñì‚°„ ªêò™ Þšõ£Á ܬñAø¶: for . } ªõOf´? 87 . int i = 1... i++. 3) W«ö»œ÷ GóL¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? # include <iostream.. j = 1. while(i <= 3) { cout << ‘\n’.h> void main() { clrscr(). } getch().loop while loop i = 1 强¬ø G¬ø«õŸøŠð´‹ 1 ( j<= I) i = 2 Þ¼º¬ø G¬ø«õŸøŠð´‹ ( j = 1 . 2) i = 3 º‹º¬ø G¬ø«õŸøŠð´‹ ( j = 1. for(i=1.i<=j.i++) cout << ‘*’. j++.

1 Gó™ ªêòô£‚è‹ 88 . Þô‚°‚ «è£Š¹ì¡ «î¬õò£ù Ëôè‚ «è£Š¹èœ ªî£ì˜¹ÁˆîŠð†´. Gó™ªðò˜ŠHèœ (Compilers) Íô‚ °Pº¬øJL¼‰¶ Þô‚°‚ «è£Š¹ è¬÷ à¼õ£‚°A¡øù. ªêò™ð£´èO¡ Þ‰î õK¬ê º¬ø¬òŠ ðì‹ 3. æ˜ Þò‚°G¬ô‚ «è£Š¹ (executable file) à¼õ£‚èŠ ð´Aø¶. 2. àò˜G¬ô ªñ£NJ™ â¿îŠð´‹ Gó™ Íô‚ °Pº¬ø (Source Code) âùŠð´Aø¶. àœ-ñì‚° Þó‡´‹ å«ó 膴Šð£†´ ñ£P¬ò ¬õˆ¶‚ ªè£œ÷ º®ò£¶. Íô‚ °Pº¬ø¬ò â‰F󈶂°Š ¹K»‹ õ®M™ ªñ£Nñ£Ÿø‹ ªêŒò «õ‡´‹. 3.1-™ 裇è. è£óí‹ Ü¶ î¼‚èŠ H¬öè¬÷ ãŸð´ˆ¶‹. ªñ£NJ¡ Þô‚èíˆ¬î„ (è†ì¬÷ ܬñŠ¬ð) êK𣘂Aø¶.6 Gó™ à¼õ£‚è‹ å¼ èEŠªð£P ªñ£NJ¡ Þô‚èíˆ¬îŠ ðò¡ð´ˆF. àœ-ñì‚° º¿¬ñ»‹ ªõO-ñì‚A¡ àìŸð°F‚°œ ܬñ‰F¼‚è «õ‡´‹. â‰Fó ªñ£N õ®M™ ñ£ŸøŠð†ì Gó™ Þô‚°‚ «è£Š¹ (Object file) âùŠð´Aø¶. Gó™ªðò˜ŠH. ªõO-ñì‚°. Gó™ªðò˜ŠHèœ â¡ð¬õ. àò˜G¬ô ªñ£NJ™ Gó™èœ â¿îŠð´A¡øù. ðì‹ 3. H¬öJ™ô£î Íô‚ °Pº¬øJL¼‰«î Þô‚°‚ «è£Š¹ à¼õ£‚èŠð´Aø¶.H¡ù™ ñì‚°è¬÷ ܬñŠðîŸè£ù MFº¬øèœ: 1. Íô‚ °Pº¬ø JL¼‰¶ â‰Fó ªñ£N‚° ñ£Ÿø‹ ªêŒ»‹ ªñ£Nªðò˜Š¹ Gó™èœ Ý°‹.

W›‚è£μ‹ GóL™ H¬ö F¼ˆF. W›‚è£μ‹ îèõ™è¬÷Š ªð£¼ˆîñ£ù ÜPMŠ¹‚ ßÁè÷£è â¿F‚ 裆´è: Ü) 8/3 â¡Â‹ èí‚W†®¡ M¬ì¬ò Þ¼ˆF ¬õ‚辋. if a > b cout << a. H¬öò£ù¶ âQ™. int 1choice. double d. 4. Þ) Y-yes. 89 . char name(10). b = 5. H¬öò£ù¶ âù‚°PŠH´è. _2choice 2. float f. W›‚è£μ‹ ÜPMŠ¹è¬÷„ êKò£ù¶. ÜPMŠ¹ êKò£ù¶/H¬öò£ù¶ è£óí‹ int A. float f. Ý) Emp_Name â¡Â‹ ñ£PJ™ “Kalam” â¡Â‹ ªî£ì‚è ñFŠH¼ˆ¶è.ðJŸC Mù£‚èœ: 1. êKò£ù Gó¬ô ⿶è: 3. W›‚è£μ‹ Gó™ ð°FèO™ àœ÷ H¬öè¬÷„ ²†´‚ 裆´è: Ü) int a = 10. int. a. è£óí‹ ÃÁè. N-no âù‚ °PŠH†´Š ðòùKìI¼‰¶ àœk´ ªðÁè.

} ß) for (int i = 1...Ý) if (a<b) && (a<0) cout << “ a is negative and . # include <iostream.. ch == ‘y’). } void main() { int i = 1... i < 10. cin >> feet... cin >> ch.h> // 5 b. clrscr(). # include iostream... cout << “\nEnter feet …”.. s += i..h> void main() { int feet.” << i << “\nSum:…” << s.. do while option == ‘y’ { cout << ‘ * ’. sum = 0... }while (cout << “ \n Continue <y/n> . W›‚è£μ‹ Gó™èœ/ Gó™ð°FèO¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? // 5 a.”.h> # include <conio.... i ++) cout << i * 2. const int inch_conversion = 12. 5. clrscr(). } input – 7 for feet 90 ..” Þ) char option = ‘Y’.h> # include <conio.... . cout << “\nConverted to inches …” << feet * inch_conversion. } cout << “\nValue of the variable i after executing the while loop . à) do { cout << ‘ * ’. while(i++ <= 5) { cout << ‘\n’ << i.

s= 0.h> void main() { int i = 1. } //5 g # include <iostream.h> void main() { clrscr(). s += d.h> void main() { clrscr().h> # include <conio. ++i) { cout << ‘\n’ << i.) { d = num % 10.h> # include <conio. j = 1.h> // 5 f # include <iostream... i++) { cout << ‘\n’ << i.x = 0. for(int i = 1. getch(). i++) { if (i%2 == 0) continue. getch(). getch(). num = num / 10. clrscr(). j++. sum = 0. } cout << “\nThe sum is . i++) x = x + i%2==0 ? i*1 : i * -1. } 91 . clrscr().num > 0. clrscr(). . if ( i > 9) break.// 5 d # include <iostream. } //5e # include <iostream. while(++i <= 5) { cout << ‘\n’ << i. } cout << ‘\n’.s = 0. getch(). do { while (j<=i) { cout << ‘#’.h> # include <conio.. cout << x. s += i. i <= 5. j = 1.” << s. for(i = 1. i++. sum = 0. i <= 5. } cout << ‘\n’ << i << ‘\t’ << sum. sum += i.h> void main() { int i = 1. for(i = 1. } while(i<= 5). getch().h> # include <conio. x. } void main() { int num = 1784.h> void main() { int i = 1.h> # include <conio. } cout << ‘\n’ << i << ‘\t’ << sum. } cout << “\nThe sum of digits of “ << x << “is : “ << s. } cout << ‘\n’ << i << ‘\t’ << sum.i <= 5. } // 5 c # include <iostream. // 5 h # include <iostream. for(. x = num.h> # include <conio. sum += i. sum += i. d = 0. for(int i = 1. clrscr().

getch().”.. } } // 5 n # include <iostream. int bool = 2. } //5 l # include <iostream.”. cout << “\nReturning to Edit Window. b—. i >= 5.h> void main() { clrscr().”.h> # include <conio.”. if (month++ == 6) cout << “\nMay . } while (0).. getch(). } void main() { clrscr().break.. else if (month == 6) cout << “\nJune . i—) cout << “Bjarne Stroustrup”.h> // 5 m # include <iostream. case 2 : cout << “\nTuesday .h> # include <conio. case 6 : cout << “\nSaturday . } 92 .”. else if (—month == 5) cout << “\nMay again .. do { cout << “\ndo loop .. case 5 : cout << “\nFriday .h> # include <conio.. } getch().”..”. case 3 : cout << “\nWednesday ..h> # include <conio. “. case 4 : cout << “\nThursday . bool—.b =4.... switch (day) { case 0 : cout << “\nSunday .//5 j # include <iostream. case 1 : cout << “\nMonday .h> # include <conio..h> //5 k # include <iostream.h> void main() { int day = 3. while(bool) { cout << bool << ‘\t’ << ++b << ‘\n’.”. } void main() { clrscr()..”.”.h> void main() { clrscr().”... int i = 0. for(i = -5. int month = 5.

20. 2..14... “2nd / 22nd day in the month” âù ªõOJ´è Þ) day 3/23 âQ™ “ 3rd / 23rd day in the month” âù ªõOJ´è. “1st day in the month” âù ªõOJ´è.... b º¿â‡.. 12. Ý) ªè£´‚èŠð†ì â‡E¡ ªî£ì˜ªð¼‚è™ (factorial) è‡ìPò¾‹. ß) day 4. (îQˆ îQ Gó™ ⿶è) 4 1 1 1 1 1 2 2 2 2 3 3 3 4 4 3 4 2 3 4 1 2 3 4 5 A B C D E F G H I J 7. 32.16... 5. ß) W›‚è£μ‹ «î£óEè¬÷ ªõOfì£èˆ î¼è. 15. Ü) day 1 âQ™... 1. ... day in the month” âù ªõOJ´è..5. 8. ab è‡ìPò¾‹. switch() ðò¡ð´ˆ¶è. Þ) n õ¬ó»œ÷ ç¬ð«ð£ù£Cˆ ªî£ì¬ó‚ è‡ìPò¾‹. 18. (while() ñì‚° ðò¡ð´ˆ¶è). Ý) day 2/22 âQ™. ç¬ð«ð£ù£Cˆ ªî£ì˜: 0.... W›è£μ‹ ªêŒFè¬÷ ªõOJ´è. 3. 1.. (for() ñì‚° ðò¡ð´ˆ¶è).6. âQ™ 4th/5th. 93 . å¼ ñ£îˆF¡ «îF¬ò àœkì£èŠ ªðŸÁ... Gó™ ⿶è: Ü) a ªñŒªò‡..

ou=Computer Lecturer..”. email=ctdsti@gmail. å¼ Gó¬ô„ ªêò™ð´ˆ¶õîŸè£ù ªî£ì‚èŠ ¹œO main() ªêòŸÃø£°‹. a<= num.03.xfact=1.Ph:9442282076 Date: 2008. a++) ffact * = a. } .Ramanathan Digitally signed by Ramanathan DN: cn=Ramanathan. a++) factorial *= a.com Location: Commercial Taxes Staff Training Institute. for (int a =1. cout << fact (x)/fact(f). for (int a=1. cout<<“\nEnter values…”.h > # include <conio. ffact = 1. cin >> x >> f.  GóL¡ c÷ˆ¬î‚ °¬ø‚A¡øù. } 94 // To print X!/F! using functions // Program .4. getch(). for (a = 1.h > # include <conio. clrscr ( ).h > int fact (int num) { int factorial = 1. f. a< = f. return factorial. Computer Lecturer.13 11:57:45 +05'30' ð£ì‹ 4 ªêòŸÃÁèœ (Functions) 4.. ªêòŸÃÁèœ. a ++) xfact * = a. c=IN. cout << “\nEnter values . f.1 # include < iostream. } void main ( ) { int x.h > void main ( ) { int x.1 º¡Â¬ó C++ Gó™èO¡ è†ì¬ñŠ¹‚ ÃÁè÷£èˆ Fè›ð¬õ ªêòŸÃÁèœ (Functions) Ý°‹..2 # include <iostream. // To print X!/F! – Program .4. cout << xfact/ffact.  °Pº¬øJ¡ ñÁðòù£‚舶‚° àî¾A¡øù. å¼ GóL¡ ªêò™ð£†´Š ð°Fè÷£è ܬõ M÷ƒ° A¡øù. cin >> x >> f. clrscr ( ).. a < = x. o=Commercial Taxed Dept Staff Training Institute.

cin >> x >> f.3 # include <iostream. for (int a=1.1 GóL™ ªî£ì˜ªð¼‚è¬ô‚ èí‚A´‹ è†ì¬÷èœ F¼‹ðˆ F¼‹ð Þó‡´º¬ø Þ싪ðŸÁœ÷ù.h > # include <conio. return factorial. } void main ( ) { int x.4.2 GóL™ «î¬õò£ù«ð£¶ fact (int num) â¡Â‹ ªêòŸÃÁ ªêò™ð´ˆîŠ ð†´œ÷¶.h > int fact (int num) { int factorial = 1. ªêòŸÃP¡ º®¬õ„ ²†´Aø¶. GóL¡ 膴Šð£†¬ìªêòŸÃÁ ܬöŠ¹‚ è†ì¬÷‚° Ü´ˆîî£è â´ˆ¶„ ªê™Aø¶. cout<<“\nEnter values…”. å¼ ªêòŸÃP¡ ð™«õÁ ð°Fè¬÷‚ 裆´‹ Üî¡ ªð£¶õ£ù è†ì¬ñŠ¬ð‚ 裇è: // To print X!/F! using functions // Program . f. return ªêòŸÃP¬ù„ ªêò™ð´ˆ¶‹ ܬöŠ¹‚ ßÁèœ . cout << fact (x)/fact(f).Program . ªêòŸÃÁèœ W›‚è£μ‹ õ¬èJ™ àî¾A¡øù:  Gó™ °Pº¬øJ¡ ñÁðòù£‚è‹ (fact( ) ªêòŸÃÁ Þ¼º¬ø ܬö‚èŠð†´œ÷¶)  å¼ ªêòŸÃP¬ù îQò£è Gó™ªðò˜ˆ¶ (Compiling) ¬õˆ¶‚ ªè£‡ì£™ å¡Á‚° «ñŸð†ì Gó™èœ Üî¬ùŠ ðA˜‰¶ªè£‡´ ðò¡ªðø º®»‹.4. Program-4. a++) factorial *= a. a<= num. âù«õ. clrscr ( ). } 95 Ü÷¹¼‚èÀì¡ Ã®ò º¡õ®¾ ßÁ.

} ªêòŸÃP¡ õ¬óò¬ø void fun (char name[] ) { cout << name.4.2 -ä e‡´‹ «ï£‚°è.”}. 2. fun (n). ªêòŸÃÁ º¡õ®¾ (ªêòŸÃP¡ ÜPMŠ¹) void main ( ) { char n [ ] = { “C++ programming….4 # include <iostream. Program-4.4. } º¡õ®¾ Gó™ªðò˜ŠH‚°‚ W›‚è£μ‹ îèõ™è¬÷ õöƒ°Aø¶: 1. fact() â¡Â‹ ªêòŸÃÁ F¼ŠHòŠ¹‹ îóMù‹ int Ý°‹. ªêò½¼¹èO¡ (arguments) â‡E‚¬è»‹ ÜõŸP¡ îóMùº‹-(char name[]) â¡ð¶ å¼ ªêò½¼¹).2 ªêò™ÃP¡ º¡õ®¾ (Function Prototype) ªêòŸÃÁèœ.h> void fun (char name [ ]) .(«ñŸè‡ì â´ˆ¶‚裆®™ fun() â¡Â‹ ªêòŸÃP¡ îóMù‹ void â¡ð. 96 . Program . ªêòŸÃÁ º¡õ®M¡ Íôñ£è å¼ ªêòŸÃÁ ÜPM‚èŠ ð´Aø¶. F¼ŠHòŠ¹‹ ñFŠ¹ ⶾ‹ Þ™¬ô â¡ð¶ ªð£¼œ. F¼ŠHòŠ¹‹ ñFŠH¡ îóMù‹. â´ˆ¶‚裆ì£è. //Program -4. GóL™ ðò¡ð´ˆîŠð´õ º¡ð£è ÜPM‚èŠðì «õ‡´‹.4 Gó¬ô‚ 裇è.

F¼ŠH ÜŠ¹‹ ñFŠ¹„ êKò£è àœ÷î£ â¡ð¬î»ñ àÁF ªêŒ¶ªè£œ÷ Gó™ªðò˜ŠH Þ‰î õ£˜Š¹¼¬õŠ ðò¡ð´ˆF‚ ªè£œAø¶.ªêòŸÃÁ º¡õ®M¡ ªð£¶õ£ù ªî£ì˜ ܬñŠ¹: <îóMù‹> <ªêòŸÃP¡ ªðò˜> <ªêò½¼¹èœ>. â´ˆ¶‚裆´: void fun(char). å¼ ªêòŸÃP¬ù ÜPM‚°‹«ð£¶‹ õ¬óòÁ‚°‹«ð£¶‹. int). for(int a = 1. void fun(char name[ ]) { cout<<name. ªêò½¼¹èœ Ü™ô¶ F¼ŠHòŠ¹‹ Þù‹ º¡õ®M™ àœ÷õŸÁì¡ ªð£¼‰îM™¬ô âQ™. int max(int a.a <= num. å¼ ªêòŸÃÁ ܬö‚èŠð´‹«ð£¶. ªêòŸÃÁ º¡õ®M¡ ºî¡¬ñò£ù ðò¡ð£´. 97 . º¡õ®¾ì¡ îò å¼ õ£˜Š¹¼ (Template) ðò¡ð´ˆîŠð´Aø¶. } ªêò½¼¹èœ name. num ÝAò¬õ ªêòŸÃPÂœ â´ˆî£÷Šð´õ¶ 裇è. } int fact(int num) { int f =1. êKò£ù ªêò½¼¹èœ ÜŠðŠð†´œ÷ùõ£ â¡ð¬î»‹. int max(int. ªêò½¼¹èO¡ ªðò˜èœ ñ£FK ñ£Pè«÷. int b). è£óí‹. º¡õ®M™ °PŠHìŠð´‹ ñ£Pèœ ªõÁ‹ Þì‹ à혈Fè÷£è«õ (place holders) °PŠHìŠð´A¡øù. H¬öªòù Gó™ªðò˜ŠH ²†®‚ 裆´‹. return f. âù«õ ÜõŸ¬ø‚ °PŠHì «õ‡®ò¶ è†ì£òI™¬ô. int max (int. Gó™ªðò˜ŠH¡«ð£¶. ªêòŸÃP‚°ˆ «î¬õò£ù îó¾è¬÷„ êK𣘈¶‚ªè£œ÷ Gó™ªðò˜ŠH‚° àî¾õ«î. ªêòŸÃP¡ õ¬óò¬øJ™ ªêò½¼¹èO¡ ªðò˜èœ(ñ£Pèœ) «î¬õŠð´A¡øù. int) â¡Â‹ º¡õ®¾ êKò£ùî£? å¼ ªêòŸÃÁ ÜPMŠH™. ªêòŸÃPÂœ ªêò½¼¹èœ â´ˆî£÷Š ð´A¡øù. a++) f *= a.

...} void main ( ) { int x1. ªêò™ð´ˆî º®»‹..3 å¼ ªêòŸÃP¬ù ܬöˆî™ å¼ ªêòŸÃP¬ù Üî¡ ªðò˜ °PŠH†´..4..h> # include <iostream... «õªø£¼ ªêòŸÃP L¼‰¶ ܬö‚è º®»‹. return a+b........5 # include <conio.. x2. Üî£õ¶.. } 98 ...... ªñŒò£ù Ü÷¹¼‚èœ (Actual Parameters) sum = add (x1.4.. cout << sum..... } å¼ ªêòŸÃP¡ ªêò™ð£´èœ: int add(int. x2). int b) { return a + b.....x2).. ªêòŸÃP¡ ªðò¼ì¡ ªñŒò£ù Ü÷¹¼‚èœ è£Ÿ¹œOò£™ HK‚èŠð†´Š H¬ø ܬ승‚ °PèÀ‚°œ îóŠð´‹. sum =add(x1.. â´ˆ¶‚裆´: // Program . sum = 0 cin >> x1 >> x2. cout<<sum. void main() { ..h> º¬øò£ù Ü÷¹¼‚èœ (Formal Parameters) int add (int a. int) { . } 膴Šð£´ ñ£ŸøŠ ð´õ¬î„ ²†´Aø¶..

x2 = 7 main() add() x1 = 5 a=5 x2 = 7 b=7 sum = Assume address of the variables : x1 = Oxf1 x2 = Oxf3 a = Oxf7 b = Oxf9 sum = Oxf6 99 address Oxf1 Oxf2 Oxf3 Oxf4 Oxf5 Oxf6 Oxf7 Oxf8 Oxf9 data 5 7 12 5 7 .5 # include <iostream.4. } Assume x 1 = 5. ܬöŠ¹‚ ßPL¼‰¶ ªêòŸÃP‚°‹ ªêòŸÃPL¼‰¶ ܬöŠ¹‚ ßP‚°‹ Þ¬ì«ò îó¾èO¡ 𣌾‚° Ü÷¹¼‚èœ õNˆîìƒè÷£Œ ܬñA¡øù. x2).5-ä G¬ù¾ Øè. ¹Fò ñ£Pè¬÷ à¼õ£‚°Aø¶.h> int add (int a. â´ˆ¶‚裆´ Gó™ Program -4.4. x2. Þš õ£Á.4. ªêòŸÃÁ îù‚ªèù Ü÷¹¼‚èO¡ ïè¬ô à¼õ£‚AŠ ðò¡ ð´ˆF‚ ªè£œAø¶. ªêò½¼¹èœ(Arguments) Ü™ô¶ Ü÷¹¼‚èœ (Parameters) Íôñ£è ªêòŸÃ«ø£´ îèõ™ ðKñ£Ÿø‹ ªêŒAø¶.} void main ( ) { int x1.h> # include <conio.4 ªêòŸÃP‚° Ü÷¹¼‚è¬÷ ÜŠH¬õˆî™ ªêòŸÃP¬ù ܬö‚°‹ ßÁ. îù‚° ÜŠH ¬õ‚èŠð´‹ ªêò½¼¹èO¡ ñFŠ¹è¬÷ Þ¼ˆF ¬õ‚è. C++ ªñ£NJ™ ªêò½¼¹èœ ªè£‡ì ªêòŸÃÁè¬÷. º¬øò£ù Ü÷¹¼‚èO™ (ªêòŸÃP¡ î¬ôŠH™ °PŠHìŠð´‹ Ü÷¹¼‚èœ) ïèªô´‚°‹. ªñŒò£ù Ü÷¹¼‚èO¡ (ܬöŠ¹‚ ßP™ °PŠHìŠð´‹ Ü÷¹¼‚èœ) ñFŠ¹è¬÷. // Program .  ñFŠ¹ Íô‹ ܬöˆ¶ (Call by value)  °PŠ¹ Íô‹ ܬöˆ¶ (Call by reference) 4. int b) { return a + b. cin >> x1 >> x2. sum = add (x. sum. Þ¼õ¬èJ™ ªêò™ð´ˆî º®»‹. cout << sum.1 ñFŠ¹ Íô‹ ܬöˆî™ (Call by Value) Þ‰îõ¬è ܬöŠH¡«ð£¶ ܬö‚èŠð†ì ªêòŸÃÁ.

int n2) { int temp. º¬øò£ù Ü÷¹¼‚è÷£ù a. clrscr ( ). getch ( ).ªñŒò£ù Ü÷¹¼‚è÷£ù x1..”... ⊫𣶫ñ. m2). 10 Back to main. m2 = 20. îó¾èœ ܬöŠ¹‚ ßPL¼‰¶. ªêòŸÃP¡ õ¬óò¬ø‚°Š 𣻋.h> # include <iomanip.h> #include <conio. temp = n1. cout <<“\n Values before invoking swap” << m1 << ‘\t’ << m2. values are 100 . cout << “\n Calling swap. } void main ( ) { int m1 = 10.h> void swap (int n1. cout << ‘\n’<<n1<<‘\t’<<n2<<‘\n’.. // Program . } ªõOf´: Values before invoking swap Calling 20 10 20 10 20 swap . b ÝAò¬õ»‹ ªõš«õÁ G¬ùõè Þ¼ŠHìƒèO™ Þ¼ˆîŠð†´œ÷ù â¡ð¬î‚ èõQˆb˜è÷£? Ýè. n1 = n2. ñFŠ¹ Íô‹ ܬö‚°‹ º¬øJ™. Values are” << m1 << ‘\t’ << m2..6 // To exchange values #include <iostream. swap (m1. n2 = temp.4. cout << “\n Back to main. x2 ÝAò¬õ»‹.

2 °PŠ¹ Íô‹ ܬöˆî™ (Call by Reference) Þ‰î º¬øJ™.º¬ø ò£ù Ü÷¹¼‚èœ.7 // To exchange values # include <iostream.ܬö‚°‹ ªêòŸÃP½œ÷ ªñŒò£ù Ü÷¹¼‚èO¡ ñ£ŸÁŠ ªðò˜è÷£è„ (alias) ªêò™ð´A¡øù. ªêò½¼¹èœ â‰îˆ îóMùƒè¬÷„ ꣘‰î¬õ«ò£ Ü«î îóMùƒèO™ ¹Fò ñ£Pè¬÷ à¼õ£‚°Aø¶.6 . º¬øò£ù Ü÷¹¼‚è÷£ù Þ‰î ñ£PèO™ ªêŒòŠð´‹ ñ£Ÿøƒèœ. ªñŒò£ù Ü÷¹¼‚èO™ HóFðLŠðF™¬ô. ã¡ âù â‡EŠ 𣘈b˜è÷£? ªêò½¼¹èœ ñFŠ¹ Íôñ£è ÜŠH¬õ‚èŠð´‹«ð£¶. Íôˆ îó¾èO¡ e«î ªêò™ð´Aø¶ â¡ð¶ Þî¡ ªð£¼÷£°‹.h> #include <conio. cout<<‘\n’<< n1 <<‘\t’<<n2<<‘\n’. int &n2) { int temp. ñFŠ¹ Íô‹ ܬöˆî™ º¬øJ™. } 101 .h> void swap (int &n1.4. temp = n1. ܬö‚èŠ ð†ì ªêòŸÃÁ. ªêò½¼¹èO¡ ñFŠ¹èœ ¹Fò à¼õ£‚èŠð†ì ñ£PèO™ ïèªô´‚èŠð´A¡øù. Program . 4. ªêòŸÃÁ îù¶ ªê£‰î„ ªêò½¼¹èO¡ e¶ ªêò™ð´‹«ð£¶ à‡¬ñJ™. º¬øò£ù Ü÷¹¼‚èO™ ªêŒòŠð´‹ ñ£Ÿøƒèœ ªñŒò£ù Ü÷¹¼‚èO™ HóF ðLŠðF™¬ô. m2 ÝAò ñ£PèO¡ ñFŠ¹èœ Þì‹ ñ£Pò¶.m1. âù«õ.4. main() ªêòŸ ÃP™ HóFðL‚èM™¬ô. n2 = temp. ܬö‚èŠð´‹ ªêòŸÃP¡ ªêò½¼¹èœ . swap () ªêòŸÃP¬ùˆ F¼ˆF ⿶«õ£‹. °PŠ¹õ¬è Ü÷¹¼‚è¬÷Š ðò¡ð´ˆF. //Program .ä G¬ù¾ Øè.4. n1 = n2.

void main ( ) { int m1 = 10.Values are” << ‘\t’ << m1 << ‘\t’<< m2. cout<<“\nValues before swap call” << ‘\t’ << m1 << ‘\t’ << m2.”. cout<<“\n Calling swap. º¬øò£ù Ü÷¹¼‚èœ °PŠ¹õ¬è â¡ð ܬõ ªñŒò£ù Ü÷¹¼‚èO¡ G¬ùõè Þìƒè¬÷«ò ²†´ A¡øù. swap(m1. m2 = 20.m2). getch ( ). m1 = Oxf1 = 10 m2 = Oxf4 = 20 102 Oxf1. W«ö»œ÷ M÷‚èƒè¬÷è 裇è: main() swap() m1=10 m2=20 n1=10 n2=20 temp m1. cout<<“\n Back to main. . è£óí‹.. clrscr().... values are º¬øò£ù Ü÷¹¼‚èO™ ªêŒî ñ£Ÿøƒèœ ªñŒò£ù Ü÷¹¼‚ èO™ HóFðLˆ¶œ÷ù. } ªõOf´: Values before invoking swap Calling 20 10 20 20 10 swap . 10 Back to main. m2 ÝAò ñ£PèO¡ G¬ùõè ºèõKèœ º¬ø«ò Oxf4 â¡è.

W«ö»œ÷ Gó¬ô Þò‚AŠ 𣘂辋: // Reference variables // Program -4. n1 Þó‡´«ñ å«ó G¬ùõè Þ¼ŠH숬î«ò °P‚A¡øù. m2) 20 10 Ýè. m1. cout << num1. ºèõK ñ£Ÿøˆ¶‚° º¡ ñ£Ÿøˆ¶‚°Š H¡ Oxf1 (n1. n1 = m1 = Oxf1 = 10 n2 = m2 = Oxf4 = 20 âù‚ ªè£œ÷ô£‹. º¬øò£ù Ü÷¹¼‚èO™ ªêŒòŠð´‹ ñ£Ÿøƒèœ ªñŒò£ù Ü÷¹¼‚èO™ âFªó£L‚°‹.º¬øò£ù Ü÷¹¼‚èO¡ °PŠ¹ (reference) â¡ð¬î Þšõ£Á M÷‚èô£‹: m1 = 10. m1-¡ °PŠ¹ â¡ð¬î.h> void main ( ) { int num1 = 10. °PŠ¹ Íô‹ ܬöˆî™ º¬øJ™. âù«õ. m1) 10 20 Oxf4 (n2.8 # include <iostream. âù‚ °PŠHìô£‹. «ñŸè‡ì ßÁèO¡ ªð£¼œ.h> # include <conio. n1 â¡ð¶. } 103 . num2 ++. int &n1 = m1. º¬øò£ù Ü÷¹¼‚èO™ ªêŒòŠð´‹ â‰î ñ£Ÿøº‹ ªñŒò£ù Ü÷¹¼‚èO™ HóF ðL‚°‹. m1-¡ ñ£ŸÁŠªðò˜ n1 â¡ð‹. Üî£õ¶. Þî¡ ªð£¼œ. & num2 = num1.

b1 ÝAò¬õ int ñ£Pèœ) â¡Á ܬñò «õ‡´‹.10) . x = add (5. a2) [a1. ªñŒò£ù Ü÷¹¼‚èÀ‚è£ù MFº¬øèœ 1. â´ˆ¶‚裆ì£è. int add (int n1.™ HóFðL‚Aø¶. num2 ÝAò Þó‡´ ñ£PèÀ‹ å«ó G¬ùõè Þ¼ŠHìˆ¬î„ ²†´ñ£Á ªêŒò º®Aø¶. a2 ÝAò¬õ int ñ£Pèœ] 2. ⡪ø™ô£‹ ܬñõ¶ H¬öò£°‹. int &n2) x= add (a1. num1. ªñŒò£ù Ü÷¹¼‚è¬÷ ñ£PèO¡ õ®M«ô«ò ÜŠH¬õ‚è º®»‹. ñFŠ¹ õ¬èJô£ù º¬øò£ù Ü÷¹¼‚èÀ‚° ñ£PL. â¡ø º¡õ®¾ ªè£‡ì å¼ ªêòŸ ÃP‚è£ù ܬöŠ¹‚ßÁ. â´ˆ¶‚裆ì£è. int add( int &n1.™ ªêŒòŠð´‹ ñ£Ÿø‹ num2.Þ‰î GóL¡ ªõOf´ 11 âù‚ A¬ì‚°‹. int n2) â¡ø º¡õ®¬õ‚ ªè£‡ì å¼ ªêòŸ ÃP‚è£ù ܬöŠ¹‚ ßÁ Þšõ£Á ܬñòô£‹: x = add (5. 10). 104 . x = add (a1. ñ£P Ü™ô¶ «è£¬õJ¡ õ®M™ ªñŒò£ù Ü÷¹¼‚è¬÷ ÜŠH¬õ‚è º®»‹. âù«õ. x = add (a1+b1. °PŠH¡ àîMò£™ num1. a1). °PŠ¹ õ¬èJô£ù º¬øò£ù Ü÷¹¼‚èÀ‚°. b1) (a1.

mi++) { cout << ‘\n’. è£óí‹: i â¡Â‹ ñ£P mi â¡ø ñ£PJ¡ °PŠ¹ (reference) Ý°‹. ºî™ º¬ø ªêòŸÃÁ G¬ø«õŸøŠð´‹«ð£¶ i-¡ ñFŠ¹ 6 ÝAM´Aø¶.9 //To print 5 stars per row and 5 such rows # include <iostream. fun_starts (mi). clrscr( ). 105 .h> void fun_starts(int &i) { int j = 5. i++) cout << ‘ ‘ <<‘*’.4. i <= j. } «ñŸè‡ì Gó™. ***** â¡Á å¼ õK M¬ì¬ò ñ†´«ñ . âù«õ. } getch(). main() -™ àœ÷ for( ) ñì‚° å«óªò£¼ º¬ø ñ†´«ñ ªêò™ð´Aø¶. for (. 䉶 õK M¬ì¬òˆ îó£¶.// Program . for (i= 1. } void main() { int mi = 1. 4. Ü«î«ïó‹ mi.¡ ñFŠ¹‹ 6 ÝAM´‹. °PŠ¹¬óJ™ °PŠH†´œ÷ð® ªõOf†¬ìˆ îó£î è£óí‹ â¡ùªõ¡Á ¹KAøî£? Þ‰î Gó™. mi<= 5.h> # include <conio.4 º¡Qò™¹„ ªêò½¼¹èœ (Default Parameters) C++ ªñ£NJ™ å¼ ªêòŸÃP¡ º¡õ®M™ º¬øò£ù Ü÷¹¼‚èO™ º¡Qò™¹ ñFŠ¹è¬÷ Þ¼ˆî¤¬õ‚è º®»‹.3.

x) â¡Â‹ Þšõ£Á Þ¼‚°‹: n = b. . x). 16 2 ܬöŠ¹‚ ßP™ ªî£ì‚è ñFŠH¼ˆî™ p=x power (b) â¡Â‹ Þó‡ì£õ¶ ܬöŠ¹‚ ßP™.” << power (b.â´ˆ¶‚裆´: // Program .. int x = 4.x) Call statement is power(b) power(b. getch ( ). cout << “\n Call statement is power(b.. cout << “\n Call statement is power(b). b = 2. ªñŒò£ù Ü÷¹¼ Þ™¬ôªò¡ð p â¡Â‹ ñ£PJ™ º¡Qò™¹ ñFŠð£ù 1 Þ¼‚°‹. n â¡ø ñ£PJ™ 2 â¡Â‹ ñFŠ¹ Þ¼ˆîŠð´‹.h> # include <conio. “ << power (b).. int p = 1) { float prd = 1. return prd. i++) prd *= n. } ªõOf´: Call statement is power (b. 106 . } void main ( ) { clrscr ( ).h> float power (float n. for (int i = 1.. x).4... . i<= p.10 // formal parameters with default values # include <iostream..

s2) << ‘\n’.  º¡Qò™¹ ñFŠ¹èœ ªêòŸÃÁ º¡õ®M™ ªêò½¼¹Š ð†®òL™ ÞÁFò£è«õ Þ싪ðø «õ‡´‹. side2 = s2 2õ¶ ܬñŠH™: side1 = s1. cout << area (s1. W«ö»œ÷ Gó¬ô Þò‚AŠ 𣘂辋: //Program . s2 = 6. cout << area (s2) << ‘\n’. ï´M«ô£ Þ싪ðø‚ Ã죶. clrscr( ). int side2=20) { return (side1 * side2). } ªõOf´: 24 80 120 ñ£PJ™ ñFŠH¼ˆî™: ºî™ ܬñŠH™: side1 = s1. getch( ). side2 = 20 3-õ¶ ܬñŠH™: side1 = s2. ð†®òL¡ ªî£ì‚èˆF«ô£.  å¼ ªêòŸÃP¡ ܬöŠ¹‚ ßP™ Cô Ü÷¹¼‚è¬÷ M†´ Mì«õ£ Ü™ô¶ Ü÷¹¼‚èœ Þ™ô£ñ«ô ܬö‚è«õ£ ‘º¡Qò™¹„ ªêò½¼¹èœ’ õN õ°‚A¡øù.11 # include <iostream h> # include <conio.4.h> int area (int side1 = 10. cout << area (s1) << ‘\n’. side2 = 20 107 .°PŠ¹:  ñ£PJ™ ªî£ì‚è ñFŠH¼ˆ¶‹ õ®M™ º¡Qò™¹ ñFŠ¹ îóŠð†´œ÷¶. } void main( ) { int s1 = 4.

i ++) cout << ch. char ch = ‘ * ‘) { cout << ‘\n’. print (50). 97). for (int i = 1.h> # include <conio. 108 .h> void print (int times.4. } void main ( ) { clrscr ( ). (char ñFŠ¹ int ñFŠð£è àœÀ¬ø Þùñ£Ÿø‹ ï¬ìªðÁ‹). âù«õ times-™ 65 â¡Â‹ ñFŠ¹ Þ¼‚°‹. 97) - times â¡Â‹ ñ£PJ™ ‘A’ â¡Â‹ ñFŠ¹ Þ¼ˆîŠ ð´‹. } M¬ì: print (50) - times â¡Â‹ ªêò½¼¹ 50 â¡Â‹ ñFŠ¬ð 㟰‹. print (‘A’. print (‘A’. âù«õ. i < = timers. print ( ).12 // arguments with default values # include <iostream. 50 º¬ø * ªõOJìŠð´‹.W›‚è£μ‹ GóL¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? // Program .

å¼ ªêòŸÃP¬ù ÜPM‚°‹ «ð£¶ Üî¡ îóMù‹ ªõOŠ ð¬ìò£è °PŠHìŠðìM™¬ôªòQ™. Þó‡´ º¡õ®¾èO½‹ F¼ŠHòŠ¹‹ ñFŠ¹ int Ý°‹. â´ˆ¶‚裆ì£è. 50 º¬ø 裆ìŠð´‹. 4. º¬øò£ù Ü÷¹¼‚èÀì¡ å¡Á‚° å¡Á â¡ø Ü®Šð¬ìJ™ ªð£¼ˆîŠð´‹. int add (int.97 â¡Â‹ ñFŠ¹ ch-™ Þ¼ˆîŠð´‹. int) float 2 char choice ( ) char 3 char * success ( ) pointer to character 4 double fact (int) double 109 . ªñŒò£ù Ü÷¹¼‚èœ.5 ñFŠH¬ùˆ F¼ŠHòŠ¹î™ â‰î ñFŠ¬ð»‹ F¼ŠHòŠð£î ªêòŸÃÁ void âù ÜPM‚èŠ ð´Aø¶. âù«õ ch-™ ‘a’ Þ¼ˆîŠð´‹. Þƒ«è. âù«õ. - print() ªñŒò£ù ªêò½¼¹èœ Þ™¬ôªò¡ð º¬øò£ù Ü÷¹¼‚èœ º¡Qò™¹ (default) ñFŠ¹è¬÷ â´ˆ¶‚ ªè£œÀ‹. int). * °P. int). W›‚è£μ‹ ܆ìõ¬í¬ò‚ 裇è: õK¬ê ⇠ªêòŸÃÁ º¡õ®¾ F¼ŠHòŠ¹‹ Þù‹ 1 float power (float. add (int. Ü„ªêòŸÃP¡ Þù‹ int âù‚ ªè£œ÷Šð´‹. âù«õ ‘a’ â¡ø ⿈¶ 65 º¬ø 裆ìŠð´‹. è£óí‹ C++ ªñ£NJ™ º¡Qò™ð£è å¼ ªêò™ÃÁ F¼ŠHòŠ¹‹ îóMù‹ int Ý°‹. int ñFŠ¹ char ñFŠð£è Þùñ£Ÿø‹ ªðÁ‹.

h> # include <conio. getch ( ).1 °PŠ¹ Íô‹ F¼ŠH ÜŠ¹î™ °PŠ¹ Ü™ô¶ ñ£ŸÁŠªðò˜ ñ£Pèœ: // Program . 5 â¡Â‹ ñFŠ¬ð âŠð®Š ªðŸø¶? count ñ£PJ¡ ñFŠ¬ð I°‚°‹«ð£¶ i-¡ ñFŠ¹ âšõ£Á ÜF èKˆî¶? count ñŸÁ‹ i ÝAò ñ£Pèœ G¬ùõèˆF™ å«ó îóM¬ù«ò ²†®‚ªè£‡´œ÷ù â¡ð«î Þ‚ è£óí‹. Þ«î«ð£ô. cout << “\ni: “ << i.13 # include <iostream. } ªõOf´: Count : 5 i:6 count ñ£P. cout << “\nCount: “ << count. int &count = i . count ++.4. Íô ñ£PJ™ ãŸð´‹ ñ£Ÿø‹ °PŠ¹ ñ£PJ™ âFªó£L‚°‹.h> void main ( ) { int i = 5. W›‚è£μ‹ GóL¡ ªõOf´ â¡ùõ£è Þ¼‚°‹ â¡ð¬î‚ è‡ìPè: 110 .5. Þ‰î‚ «è£†ð£†®¡ Ü®Šð¬ìJ™.4.

y = 30. b ÝAòõŸP™ ⶠªðK«î£ Üî¡ °PŠ¬ðˆ F¼ŠHòŠ ¹‹. getch ( ). } void main ( ) { int x = 20. else return b. cout << “\n Value of x is : “ << x.y) = -1.h> int &maxref (int &a. âù«õ. cout << “/n Maximum is:“<< max. a. maxref () â¡Â‹ ªêòŸÃÁ æ˜ int Þù ñ£P‚°Kò °PŠH¬ùˆ (reference) F¼ŠHòŠ¹Aø¶. else return b.15 # include <iostream h> # include <conio. } void main ( ) { int x = 20.14 # include <iostream h> # include <conio. int &b) { if (a>b) return a.4. maxref(x. return a.y) â¡Â‹ ªêòŸÃÁ ܬöŠ¹.// Program . y = 30. } 111 . W›‚è£μ‹ GóL¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? // Program 4. max â¡Â‹ ñ£P y-¡ ñFŠ¬ðŠ ªðÁAø¶. max = 0. maxref (x.y). cout << “\n Value of y is: “ <<y. max = 0. int &b) { if (a > b). max = maxref (x. } ªõOf´: Maximum is : 30 «ñŸè‡ì GóL™.h> int & maxref (int &a.

GóL¡ c÷ˆ¬î‚ °¬ø‚°‹. ñFŠH¼ˆ¶ ßP¡ ÞìŠð‚è‹ b Þ싪ðÁ‹. 112 . Gó™ªðò˜ŠH¬ò ªêòŸÃÁ õ¬óòÁ‚èŠð†´œ÷ Þ숶‚°„ î£õ„ ªêŒ¶. °PŠð£è„ ªêòŸÃÁ CPî£è (°¬ø‰î â‡E‚¬èJô£ù è†ì¬÷èœ) Þ¼‚°‹«ð£¶. ªêò™ÃÁ ܬöŠ¹. âù õ¬óòÁŠH¡. Gó™ªðò˜ŠH™ H¬ö A†´‹. Üî£õ¶. è£óí‹ a. b â¡Â‹ ñ£P‚è£ù °PŠ¬ðˆ F¼ŠHòŠ¹‹ main() ªêòŸÃP™ b-‚° Þ¬íò£ù ñ£P y Ý°‹. y-™ -1 Þ¼ˆîŠð´‹. âù«õ Cô Å›G¬ôèO™. int b). å¼ °PŠH¬ùˆ F¼HòŠ¹‹ ªêòŸÃP¡ ܬöŠ¹‚ ßÁ å¼ ñFŠH¼ˆ¶‹ ßP¡ ÞìŠð‚è‹ Þ싪ðø º®»‹.ªõOf´: Value of x is : 20 Value of y is : -1 °PŠ¹: 1. b ÝAò ñ£PèO¡ ªêò™ð£†ªì™¬ô maxref () ªêòŸÃP‚°œ ñ†´«ñ. õôŠð‚è‹ -1 àœ÷¶. F¼ŠHòŠð™. Þˆî¬èò ñèœ å¼¹øI¼‚è. å¼ ªêòŸÃP¬ù ܬö‚°‹ ßÁ. int & maxref (int a. âù«õ. Hø° ܬöŠ¹‚ ßÁ‚° Ü´ˆF¼‚°‹ ݬ킰ˆ î£õ„ ªêŒAø¶. å¼ °PŠ¹ Þù„ ªêòŸÃP¡ º¬øò£ù Ü÷¹¼‚èœ âŠ«ð£¶«ñ °PŠ¹ Þù Ü÷¹¼‚è÷£è«õ Þ¼‚è «õ‡´‹.6 inline ªêòŸÃÁèœ ªêòŸÃÁèOù£™ ãŸð´‹ ñè¬÷ L†´œ«÷£‹:  㟪èù«õ ð†®ò Gó™ °Pº¬øJ¡ ñÁðòù£‚è‹. 4. è£óí‹. «ñŸè‡ì â´ˆ¶‚裆®™. 3. Þ¶ ªêšõ«ù G¬ø«õø Ü´‚èƒè¬÷ (stacks) ༠õ£‚A‚ ¬èò£÷ «õ‡®ò Ã´î™ «õ¬ô Gó™ªðò˜ŠH‚° àœ÷¶. Þîù£™ GóL¡ ªêò™ð´ «õè‹ °¬øAø¶. 2. G¬ùõèˆ¬î„ C‚èùñ£èŠ ðò¡ð´ˆî à. maxref() ªêòŸÃÁ ܬöŠ¹. ªêò½¼¹èœ ÝAò¬õ ªî£ì˜ð£ù îQ„CøŠ¹ ݬíèœ CôõŸ¬ø„ «êIˆ¶ ¬õŠð Þˆî¬èò Ü´‚èƒèœ «î¬õŠð´A¡øù.

4. Program-4. 113 . return ßP™ àœ÷ (inches * 12) â¡Â‹ «è£¬õò£™ ðFh´ ªêŒòŠð´‹. ܈î¬èò ªêòŸÃÁèœ inline ªêòŸÃÁèœ âùŠð´A¡øù. Ýù£™ ÜFè G¬ùõè Þ숬î â´ˆ¶‚ªè£œÀ‹. int inches = 45. int inches = 45.4. W«ö»œ÷ â´ˆ¶‚裆´è¬÷‚ 裇è: // Program . } «ñŸè‡ì â´ˆ¶‚裆®™ àœ÷ð®. getch(). convert_feet (inches) â¡Â‹ ܬöŠ¹‚ßÁ. Ü‰î„ ªêòŸÃP¡ è†ì¬÷è¬÷ GóŠHŠ ðFh´ ªêŒ¶M´‹.h> # include <conio.16 // inline functions # include <iostream. °PŠ¹: inline â¡Â‹ CøŠ¹„ªê£™. Gó™ªðò˜ŠH‚°ˆ îóŠð´‹ «è£K‚¬è Ý°‹.Gó™ªðò˜ŠHò£ù¶ ªêòŸÃÁ ܬöŠ¹‚ßÁ Þ¼‚°IìˆF™. ªêòŸÃP¬ùŠ ðFLì™ âùŠð´Aø¶. inline ªêòŸÃÁ Íô GóL™ ê£î£óí„ ªêòŸÃÁ «ð£¡«ø «î£ŸøñO‚°‹. Ýù£™ Gó™ªðò˜ŠH¡«ð£¶ (compiling time) ªêòŸÃP¡ è†ì¬÷èœ º¿¬ñ»‹ ܬöŠ¹‚ ßÁ‚°Š ðFô£è ÜŠð®«ò GóL™ ªê¼èŠð†´M´‹.h> # include <conio.h> void main() { clrscr().16. cout << convert_feet(inches). Cô «õ¬÷èO™ Gó™ªðò˜ŠH. } void main() { clrscr(). å¼ ªêòŸÃP¬ù inline ªêòŸÃø£è ÜPM‚è «õ‡´‹ âQ™. Þ‰î õêF. Þ‰î‚ «è£K‚¬è¬òŠ ¹ø‚èEˆ¶M†´„ ê£î£óí ªêòŸÃø£è«õ è¼F‚ªè£œÀ‹. inline ªêòŸ ÃÁèœ «õèñ£è„ ªêò™ð´‹. } # include <iostream.h> // working of Program . getch().16 // inline functions inline float convert_feet(int x) { return x * 12. cout << inches * 12.™ 裆®»œ÷ð® ªêòŸÃP¡ î¬ôŠH™ inline â¡Â‹ CøŠ¹„ ªê£™¬ô «ê˜ˆ¶‚ªè£œ÷ «õ‡´‹.

àœ÷¬ñ õ¬óªò™¬ô (Local scope) 2. a = b.7. getch( ). b = 20. Þù‚°¿ õ¬óªò™¬ô (Class scope) 4. // local to this if block temp = a.4. } • àœ÷¬ñ ñ£P.4.1 àœ÷¬ñ õ¬óªò™¬ô (Local Scope) // Program . • æ˜ àœ÷¬ñ ñ£PJ¡ õ¬óªò™¬ô ܶ õ¬óòÁ‚èŠ ð†´œ÷ ªî£°F‚°œ ñ†´«ñ. 114 . C++ ªñ£NJ™ ° õ¬èò£ù õ¬óªò™¬ôèœ àœ÷ù.h # include <conio. ܬõ: 1. b. • æ˜ àœ÷¬ñ ñ£P¬ò ܶ ÜPM‚èŠð†´œ÷ ªî£°F‚° ªõOJL¼‰¶ Üμè º®ò£¶. å¼ ªî£°F‚°œ (Block) õ¬óòÁ‚èŠð´Aø¶.17 // to demonstrate local variable # include < iostream. if (a > b) { int temp. ªêò™ÃÁ õ¬óªò™¬ô (Function scope) 3.7 ñ£PèO¡ õ¬óªò™¬ô (scope) MFº¬øèœ ‘õ¬óªò™¬ô’ â¡ð¶ å¼ ñ£PJ¡ ÜμAò™¬ð‚ (accessibility) °P‚Aø¶. cout << ‘\n” <<a << ‘\n” <<b. a = 10. «è£Š¹ õ¬óªò™¬ô (File scope) 4.h> void main( ) { int a. b = temp. } cout << ‘\n Descending order…’.

18 àœ÷¬ñ ñ£PJ¡ õ¬óªò™¬ô¬ò M÷‚°Aø¶. 115 . ÜõŸP¡ õ¬óªò™¬ô¬ò‚ °PŠH´è.Program -4. Error in line no. //Program . å¼ è†ì¬÷ˆ ªî£°F â¡ð¶ ªïO¾ ܬ승‚°PèÀ‚°œ ܬñ‰F¼‚°‹. if (a > b) { int temp.4. 13 The variable temp is not accessible àœ÷¬ñ ñ£PèO¡ õ£›ï£œ ܬõ ܬñ‰¶œ÷ è†ì¬÷ˆ ªî£°F ªêò™ð†´ º®»‹õ¬ó ñ† ´«ñ. • àœ÷¬ñ ñ£Pèœ Ü¬õ ÜPM‚èŠð†´œ÷ è†ì¬÷ˆ ªî£°F‚° ªõO«ò ÜPòŠð´õF™¬ô. Program. } Þ‰î Gó¬ô Gó™ªðò˜‚°‹ «ð£¶. b. a = 10 b = 20. • GóL¡ 膴Šð£´ å¼ è†ì¬÷ˆ ªî£°F‚°œ ¸¬ö»‹«ð£¶.18 # include <iostream. temp = a.19 GóL™ àœ÷¬ñ ñ£Pè¬÷ ܬìò£÷ƒ 裆´è.h> # include <conio. Gó™ªðò˜ŠH å¼ H¬ö ²†´‹ ªêŒF¬ò‚ 裆´‹. ÜõŸP¡ è†ì¬÷ˆ ªî£°Fèœ ªêò™ð†´ º®‰î¾ì¡ àœ÷¬ñ ñ£Pèœ ÜN‚èŠð´A¡øù.h> void main ( ) { int a. getch ( ). • àœ÷¬ñ ñ£Pèœ Ü¬õ ÜPM‚èŠð†´œ÷ è†ì¬÷ˆ ªî£°F ªêò™ð´‹«ð£¶ ñ†´«ñ Gô¾‹. Üî¡ àœ÷¬ñ ñ£Pèœ à¼õ£‚èŠð´A¡øù. b = temp. ªõO«òÁ‹«ð£¶ ܬõ ÜN‚èŠð´A¡øù. a= b.4. } cout << a << b << temp.

x 2. ªêòŸÃÁ õ¬óªò™¬ô ªè£‡ì å¼ ñ£PJ¡ õ£›ï£œ. Üî¡ õ£›ï£œ ܉î Gó™ ªêò™ð†´ º®»‹ õ¬ó c®‚°‹. «è£Š¹ õ¬óªò™¬ô ªè£‡ì ñ£PJ¡ õ¬óªò™¬ô ܉î GóL¡ º¿¬ñ»‹ MKAø¶.3 «è£Š¹ õ¬óªò™¬ô (File Scope) ܬùˆ¶‚ è†ì¬÷ˆ ªî£°FèÀ‚°‹ ªêòŸÃÁèÀ‚°‹ «ñô£è (°PŠð£è main() ªêòŸÃP‚° «ñ«ô) ÜPM‚èŠð´‹ ñ£P. ÜîÂœ Þ¼‚°‹ while(). å¼ ªêòŸÃP¡ º¬øò£ù Ü÷¹¼‚èO¡ õ¬óªò™¬ô ªêòŸÃÁ õ¬óªò™¬ô ªè£‡ì¬õ.4. Program-4.// Program .h> void main ( ) { int flag = 1.2 ªêòŸÃÁ õ¬óªò™¬ô (Function Scope) å¼ ªêòŸÃPÂœ ÜPM‚èŠð´‹ ñ£PèO¡ õ¬óªò™¬ô. Ü‰î ªêòŸÃP¡ è†ì¬÷ˆ ªî£°F ñŸÁ‹ ܈ªî£°F‚°œ ܬñ‰¶œ÷ à†-ªî£°Fèœ Ü¬ùˆ¶‚°‹ MKAø¶. if (a > x) { int j.19 # include <iostream. «è£Š¹ õ¬óªò™¬ô ªè£‡ì‹. 4.7. k k :else { } ªî£°F‚°œ ñ†´‹ 4. a = 100. while (flag) { int x = 200. Ü‰î„ ªêòŸÃÁˆ ªî£°FJ¡ õ£›ï£œ õ¬óò£°‹. 116 . j j : if ( a > x ) { } ªî£°F‚°œ ñ†´‹ 3.7. if() ÝAò à†-ªî£°F èÀ‚°œÀ‹ Üμè º®»‹. ------} else { int h.19.™ àœ÷ flag â¡Â‹ ñ£P¬ò main() ªêòŸÃÁ º¿¬ñ »‹ Üμè º®»‹. -----} } } àœ÷¬ñ ñ£Pèœ õ¬óªò™¬ô x: while( ) ªî£°F‚°œ 1.

°PŠHìŠð†´œ÷¬î «ï£‚A m ˜ è ÷ £ ? :: â ¡ ð ¶ õ ¬ ó void main() ªò™¬ô b˜ñ£QŠ¹„ ªêòŸ { °P âùŠð´Aø¶. W«ö»œ÷ Gó¬ô «ï£‚°è. ªè£‡ì ñ£Pèœ å«ó ªðòK™ } Gô¾‹ Å›G¬ôèO™ Þ„ ªêòŸ°P à.... num â¡Â‹ ñ£P main()-‚° àœÀ‹. .7. °P ðò¡ð´Aø¶. àœ÷¬ñ cout << num << ‘\t’ <<++::num. void fun() { cout << i. ñ£Pè¬÷‚ °PŠHì Þ„ªêòŸ num = num + ::num. ªõO«ò «è£Š¹ õ¬óªò™¬ô ªè£‡ì‹ ÜPM‚èŠð†´œ÷¬î‚ èõQˆb˜è÷£? :: num âù‚ int num = 15... ñ†ìˆF™ ÜPM‚èŠð†´œ÷ int num = 5.21 # include <iostream.h> 117 .4. } } 4..4.h> int i = 10... } void main() { cout << i.. ñŸÁ‹ «è£Š¹ õ¬óªò™¬ô getch(). while (i) { .h> # include <conio..// Program . «è£Š¹ clrscr(). // Program .h> # include <conio.4 õ¬óªò™¬ô ªêòŸ°P (Scope Operator) õ¬óªò™¬ô ªêòŸ°P å¼ ñ£PJ¡ ñ¬ø‰¶ Aì‚°‹ õ ¢ ¬óªò™¬ô¬ò ªõO‚ ªè£í¼‹.20 // To demonstrate the scope of a variable // declared at file level # include <iostream.

(Ü) Procedural -fuction() -ªêò½¼¹è¬÷ ãŸè£î. M¬ì: void Procedural-function (void). â‰î ñFŠ¬ð»‹ F¼ŠHòŠð£î ªêòŸÃÁ. M¬ì: void fun-default (float. void Procedural-function( ).5 Þù‚°¿ õ¬óªò™¬ô ð£ì‹ 6-™ Þ¶ðŸP M÷‚èŠð´‹. 118 . int ñFŠ¬ðˆ F¼ŠHòŠ¹‹ ªêòŸÃÁ. â‰î ñFŠ¬ð»‹ F¼ŠHòŠð£¶. ðJŸC Mù£‚èœ 1. M¬ì (i) int Manipulative-function(double) .7. Ü™ô¶.å¼ double Þù„ ªêò½¼¬ð ãŸÁ. ÜõŸÁœ å¡Á º¡Qò™¹ int ñFŠ¬ð‚ ªè£‡®¼‚°‹. (Ý) Manupulative-function() .4. Ü™ô¶ (ii) int Manipulative-function(double d). ñŸø¶ float ñFŠð£°‹.Þó‡´ ªêò½¼¹è¬÷ 㟰‹. ªè£´‚èŠð†ì M÷‚èƒèO¡ Ü®Šð¬ìJ™ W›‚è£μ‹ ªêòŸÃÁ º¡õ®¾è¬÷‚ è†ì¬ñ‚辋. int num = 10). Ü™ô¶ (iii) Manipulative-function (double) (Þ) fun-default() .

cout << ‘\n’. W›‚è£μ‹ ªêòŸÃÁ º¡õ®¾èO™ H¬öè¬÷„ ²†´è: Ü. ºîô£õ¶ ªêò½¼¹ pi-J¡ ñ£ø£ ñFŠ¹¬ìò¶. i++) cout << ch. b). int Þù‚ °PŠ¬ðˆ F¼ŠHòŠ¹‹. Ý. char ch) { cout << ‘\n’. i <=times. float prd (int a. à.(ß) return-reference-fun() -Þó‡´ int Þù„ ªêò½¼¹è¬÷ ãŸÁ. 3.14). (à) multi-arguments() -Þó‡´ float Þù„ ªêò½¼¹è¬÷ 㟰‹. b). } 119 . int fun (int. for (int i =1. â‰î ñFŠ¬ð»‹ F¼ŠHòŠð£¶. float & a). float average (a. void strings(char[ ]). W«ö»œ÷ ªêòŸÃP¬ù ܬöŠðˆ «î¬õò£ù ܬùˆ¶‹ ªè£‡ì main() ªêòŸÃP¬ù õ¬óòÁˆ¶‚ 裆´è. int default -arg (int a=2. 2. M¬ì: void multi-arguments (float const pi. void line (int times. double = 3. M¬ì: int & char-reference-fun(int&. int b). int&). int. Þ. Þó‡ì£õ¶ ªêò½¼¹ °PŠ¹ Þùˆ¬î„ ꣘‰î¶. ß.

. } void main( ) { cout << xyz(9. . } 120 .. } } void f1(char g) x. { i ...ªêòŸÃÁ { õ¬óªò™¬ô ... Þ‰î GóL™ ðò¡ð´ˆîŠð†´œ÷ ñ£PèO¡ õ¬óªò™¬ôè¬÷‚ °PŠH´è: M¬ì: # include <iostream.Üî¡ ªî£°F‚°œ ñ†´‹ int i = 0....... . W›‚è£μ‹ Gó™èO½œ÷ H¬öè¬÷„ ²†´è: Ü) include <iostream. 27).b ... int n) { M¬ì: ªêòŸÃP¡ ªî£°F‚°œ m â¡Â‹ ñ£P¬ò ÜPM‚è Þòô£¶. void f1 (char)... n = m * n.h> float a. a.. y ... y.f1() short x. g .. int m = 10...ªêòŸÃÁ õ¬óªò™¬ô -main() char ch. b .... return n.... } 5. .....4....«è£Š¹ õ¬óªò™¬ô int main ( ) { ch .h> xyz (int m.

°PŠ¹ õ¬èò£è Þ¼Šð ªñŒò£ù Ü÷¹¼¬õ ñFŠ¹ õ®M™ ÜŠH ¬õ‚è Þòô£¶. å¼ «è£¬õJ¡ ð°Fò£è Þ싪ðø º®ò£¶. } Þ. void main( ) { int val = 5. } divide (int v) { return v/2. ªêòŸÃÁ ܬöŠ¹. void main ( ) { int x = xyz ( ) . # include <iostream. âù«õ. } 121 . divide (int).h> void counter (int & a) { ++ a. } 6. } void xyz ( ) { return ‘\0’ . val = divide (::val/val). W›‚è£μ‹ Gó™èO¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? Ü.} void main ( ) {counter (50).Ý. M¬ì: º¬øò£ù Ü÷¹¼. M¬ì: void Þùñ£è ÜPM‚èŠð†´œ÷ ªêòŸÃPÂœ return è†ì¬÷ Þ싪ðø‚ Ã죶.h> void xyz ( ). # include <iostream. # include <iostream. cout << :: val<<val.h> M¬ì : 101 int val = 10.

getch( ). # include <iostream. x = incre (x). x --. val = divide (400) = = 40. cout << “\In Val. cout << x.” << val. for (int i = 1.h> int incre (int a) M¬ì : 10 { return a++.} void main( ) { int val = -1. } ß. } cout << ‘\n’. } void main( ) { int x = 10.h> void line( ) { static int v = 5. # include <iostream. } Þ. i ++) line( ). # include <iostream. int x = v . M¬ì : 1 (i) divide(400) â¡ø ܬöŠ¹ 40-ä M¬ìò£èˆ  (ii) divide(400)==40 â¡ð¶ 40==40 âù‚ ªè£œ÷Šð†´. i < = 5.h> # include <iostream. } M¬ì : ***** **** *** ** 122 .-. Gð‰î¬ù ‘êK’ â¡ð val-¡ ñFŠ¹ 1 Ý°‹. while (x) {cout << ‘ * ‘.h> divide (int v) { return v / 10.Ý. } void main( ) { clrscr( ).

à. (ß) int prime(int) â¡Â‹ ªêòŸÃP¬ù õ¬óòÁ‚辋.h> M¬ì : Val : 50 first (int i) { return i++. int) âù å¼ ªêòŸÃP¬ù õ¬óòÁ‚辋. îóŠð´‹ ⇠Þó†¬ìŠð¬ì âQ™ ‘E’ âù¾‹. Þ„ªêòŸÃP¬ù Þò‚A. factorial (n)-¡ ñFŠ¬ð ÜPò main( ) ªêòŸÃP¬ù ⿶è. Þ™¬ô«ò™ -1 âù¾‹ M¬ì îó«õ‡´‹. } 7. (Þ) char odd-even-check(int) â¡Â‹ ªêòŸÃP¬ù õ¬óòÁ‚辋.¡ ªêò™ð£†¬ì„ «ê£F‚è main() ªêòŸÃP¬ù ⿶è. æ˜ â‡E¡ ªî£ì˜ªð¼‚è™ ñFŠ¹ ÜP»‹ º¬ø: 5-¡ ªî£ì˜ªð¼‚è™ =1x2x3x4x5. cout << “\n Val: “ << val. (Ý) unsigned long int factorial(int) âù å¼ ªêòŸÃP¬ù õ¬óòÁ‚è ¾‹. # include <iostream. int. Þ„ªêòŸÃÁ. val = val * val/val val = second (val). àKò ªêŒF¬ò ªõOJì main() ªêòŸÃP¬ù â¿F‚ 裆´è. Gó™èœ ⿶è: (Ü) float cube (int. } void main ( ) { int val = 50. Þ™¬ô«ò™ ‘O’ âù¾‹ M¬ì îó«õ‡´‹. val = first (val). Þ„ªêòŸÃÁ. îóŠð´‹ ⇠ðè£ â‡ âQ™ 1âù¾‹. } second (int x) { return x —. Þ„ªêòŸÃP¬ù Þò‚A. 123 . àKò ªêŒF¬ò ªõOJì main() ªêòŸÃP¬ù â¿F‚ 裆´è. cube() .

o=Commercial Taxed Dept Staff Training Institute. else max = c. Computer Lecturer. c=IN. åŠd´ Þšõ£Á Þ¼‚°‹: if (a > b) max = a. else if (b > c) max = b. å«ó îóMùˆ¬î„ «ê˜‰î ðô ñFŠ¹è¬÷‚ ªè£‡®¼‚°‹. email=ctdsti@gmail.Ramanathan Digitally signed by Ramanathan DN: cn=Ramanathan.13 11:58:14 +05'30' ð£ì‹ 5 è†ì¬ñŠ¹ˆ îóMù‹ .ÜEèœ (Structured Data Type . Ý) ªî£°FJ™ Í¡Á â‡èœ Þ¼ŠH¡. else max = b. å¼ îó¾ˆ ªî£°FJ™ åš«õ£˜ àÁŠð£è ÜμA„ ªêòô£‚°õ¶ è®ùñ£ù ðEò£è Þ¼‚°‹. º¡Â¬ó C++ ªñ£NJ™ ÜE â¡ð¶ î¼M‚èŠð†ì îóMù‹ Ý°‹. îó¾èœ ÜFèñ£è Þ¼‚°‹«ð£¶.03.1.Ph:9442282076 Date: 2008..Arrays) 5.com Location: Commercial Taxes Staff Training Institute. ªè£´‚èŠð†ì â‡èO¡ ªî£°FJ™ ªðKò â‡¬í‚ è‡ìPî™: Ü) ªî£°FJ™ Þó‡´ â‡èœ Þ¼ŠH¡. 124 . åŠd´ Þšõ£Á Þ¼‚°‹: if (a > b) && (a > c) max = a. ou=Computer Lecturer. W›‚è£μ‹ Å›G¬ôè¬÷ «ï£‚°è: 1.. â´ˆ¶‚裆ì£è.

max = 0 . if ߬ø «ï£‚Am˜è÷£? ÜFèñ£ù îó¾è¬÷ âOî£è‚ ¬èò£÷. ÜE â¡ð¶ å«ó îóMùˆ¬î„ «ê˜‰î ñ£PèO¡ Fó†´ Ý°‹. 125 . i = 0.Þ) ªî£°FJ™ ° â‡èœ Þ¼ŠH¡. å«ó îóMùˆ¬î„ «ê˜‰î àÁŠ¹èO¡ ªî£°F æ˜ ÜEò£è ÜPM‚èŠð†´œ÷¶. 30. 40. åŠd´ Þšõ£Á Þ¼‚°‹: if (a > b && a > c && a > d) max = a. Üî£õ¶. cout << “\n The largest number is” << max. ÞŠ«ð£¶. 20 ÝAò â‡èO™ 40 â¡ø â‡¬í ªõOJ´Aø¶. 30. W«ö»œ÷ è†ì¬÷ˆ ªî£°F¬ò «ï£‚°ƒèœ: int a [4] = { 10. ªè£´‚èŠð†ì â‡èO¡ ð†®òL™ ªðKò â‡¬íˆ b˜ñ£Q‚Aø¶. i ++) if a [i] > max max = a [i] . for (. 10. i < 4. 40. else max = d. ÜEJ¡ àÁŠ¹è¬÷ å¼ ªð£¶Šªðòó£™ °PŠHì Þò½‹. ÜFèñ£ù îó¾è¬÷‚ ¬èò£œõ¶ âOî£è Þ¼‚裶 â¡ðF™ äòI™¬ô. else if (b > c && b > d) max = b. «ñŸè‡ì è†ì¬÷ˆ ªî£°F. Ýè. â‡E‚¬è ÜFè‹ Ýè Ýè åŠd´èÀ‹ ÜFèñ£õ¬î‚ èõQˆb˜è÷£? îó¾è¬÷„ ªêòô£‚è «ñŸè‡ì õNº¬øè¬÷Š H¡ðŸPù£™. 20}. else if (c > d) max = c.

â¡Â‹ è†ì¬÷. [3] â¡ð¶ Wªö£†´ (Subscript) Ü™ô¶ Þì Þ¼Š¹ (position) Ý°‹. 5. num_array â¡ð¶ ÜEJ¡ ªðò˜. âù«õ 5 x 2 = 10 ¬ð†´èœ «î¬õ).ÜEJ™ Þ¼õ¬è à‡´: 1) å¼ðKñ£í‹: °PŠH†ì â‡E‚¬èJ™ å«ó Þù àÁŠ¹è¬÷‚ ªè£‡ì¶. ÜEJ¡ è£õ¶ àÁŠH™ 99-ä Þ¼ˆ¶Aø¶. int num_array[5]. ðì‹ 5. ‘num_array â¡ð¶ 䉶 º¿â‡ ñFŠ¹ è¬÷‚ ªè£‡ì æ˜ å¼ðKñ£í ÜE’ â¡ð‹. ÜEJ™ àÁŠH¡ Þì Þ¼Š¹ (position)ÞõŸP¡ Íô‹ Üμè º®»‹. 2) ðôðKñ£í‹: °PŠH†ì â‡E‚¬èJ™.‚° 嶂èŠð†´œ÷ G¬ùõè Þì‹ 10 ¬ð†´èœ Ý°‹.2. ÜEJ¡ åš«õ£˜ àÁŠ¬ð»‹ ÜEJ¡ ªðò˜. 126 .1 å¼ðKñ£í ÜE ÜEJ¡ àÁŠªð‡E‚¬è ⊫𣶋 «ï˜ñ (positive) â‡í£è Þ¼‚°‹. å¼ðKñ£í ÜE (Single Dimensional Array) å«ó Þùˆ îó¾èO¡ ð†®ò™è¬÷‚ ¬èò£÷ å¼ðKñ£í ÜEèœ àè‰î¬õ Ý°‹. â¡Â‹ ÜPMŠH¡ ªð£¼œ. å¼ðKñ£í ÜE Þšõ£Á ÜPM‚èŠð´Aø¶: int num _array [5]. å¼ðKñ£í ÜEè¬÷ àÁŠ¹è÷£è‚ ªè£‡ì¶. è†ì¬÷ ܬñŠ¹: îó¾ Þù‹ Þì ªõO ÜEJ¡ ªðò˜ [ Ü÷¾ ] . è£óí‹ ÜF™ 䉶 int àÁŠ¹èœ àœ÷ù. num_array. â´ˆ¶‚裆ì£è. num_array[3] = 99. (æ˜ int ñFŠ¹‚° 2 ¬ð†´èœ «î¬õ.

7} âùˆ ªî£ì‚è ñFŠH¼ˆ¶ ßP¡ Íô‹ b˜ñ£Q‚èŠð´Aø¶. val â¡Â‹ ÜEJ¡ àÁŠªð‡E‚¬è i â¡Â‹ ñ£PL Íô‹ °PŠHìŠð†´œ÷¶. 5.G¬ùõè 嶂W´ Þšõ£Á Þ¼‚°‹: num_array .õ¶ â´ˆ¶‚裆®™. iv). number[3] ++ è£õ¶ àÁŠH™ Þ¼ˆîŠð†´œ÷ ñFŠ¹ å¡Á I°‚èŠð´‹. {1. 7 àÁŠ¹èœ ÜEJ¡ Ü÷¬õˆ b˜ñ£Q‚Aø¶. è£óí‹ ãŸèˆî° Wªö£†´èœ 0 ºî™ 4 õ¬ó ñ†´«ñ.Þ™ °PŠHìŠð´‹ àÁŠH¬ùˆ F¬óJ™ 裆´‹. ÞŠ«ð£¶. v) int days [ ] = { 1.5. 3.M™ ªî£ìƒ°‹. number[3] = number[2] Í¡ø£õ¶ àÁŠH¡ àœ÷ì‚般î ÜEJ¡ è£õ¶ àÁŠH™ Þ¼ˆ¶‹. Program .ÜEJ¡ ªðò˜ 0 1 2 Wªö£†´èœ Þ¼ˆîŠð†´œ÷ ñFŠ¹ (è£õ¶ àÁŠ¹) 3 99 ÜEJ¡ Wªö£†´ ⊫𣶫ñ 0. ÜE¬ò‚ ¬èò£œõîŸè£ù â´ˆ¶‚裆´èœ: cin >> number[4] ÜEJ¡ ä‰î£õ¶ àÁŠ¹‚° ñFŠ¬ðŠ ªðŸÁ‚ ªè£œAø¶. 2. 4.õ¶ â´ˆ¶‚裆®™. 7}. ÜEJ™ G蛈îŠð´‹ Ü®Šð¬ì„ ªêò™ð£´è¬÷ ܶ M÷‚°Aø¶. num_array[5] â¡Â‹ ßÁŠ H¬öò£ù¶. (v). cout<< number[subscript] subscript. 5. 4. 6. days â¡Â‹ ÜEJ¡ àÁŠªð‡E‚¬è 7 â¡ð¶ ñ¬øºèñ£è à혈îŠð†´œ÷¶. 2.1ä «ï£‚°ƒèœ. number [++a] = 10 ++a .Ý™ °PŠHìŠð´‹ ÜE àÁŠH™ 10 â¡Â‹ ñFŠ¹ Þ¼ˆîŠð´‹. iv) const i = 10. double val [i]. âšõ£ªøù áA‚è º®Aøî£? Ý‹. 127 . iii) char name [30]. ÜE ÜPMŠH¡ êKò£ù Hø õ®õƒèœ: i) int array [100]. ii) float exponents [10]. 3. âù«õ num_array â¡Â‹ ÜE ñ£PJ¡ Wªö£†´èœ 0 ML¼‰¶ 4 õ¬ó Þ¼‚°‹.

ctr++) { cout << “\nEnter value . cin >> a[ctr]. sum = 0. } // generating sum of all the elements // stored in array for(ctr = 0. void main() { for(. ctr < 5... getch().” << sum.. cout << “\nSum of the elements .h> # include <conio. sum.h> int a[5]. clrscr().ctr = 0. ctr++) cout <<‘\t’ << a[ctr].ctr++) sum+= a[ctr].”.5.ctr<5.W«ö»œ÷ Gó™è¬÷ Þò‚A ªõOf†¬ì «ï£‚°è: // Program . // display values stored in array for(ctr = 0. ctr<5.1 // arrays and basic manipulations on // arrays # include <iostream. } 128 .

j —) reverse [j] = even [i]. clrscr ( ).// try out // Program – 5. int reverse [3]. i < 5. i++. i<3. j—) cout << ch [j]. ‘b’. int j = 2. i++) cout << ch[ i]. 4}. } ªõOf´: 0 4 1 2 4 0 129 .h> char ch [ ] = {‘a’. getch().3 # include <iostream. getch ( ). i<3. for (i=0. i++) cout ‘\t’ << even [i] << ‘\t’ << reverse [i] << ‘\n’. j>=0.h> # include <conio. 2.2 ªõOf´: abcdeffedcba # include <iostream. ‘e’.5. for (j=4. ‘d’. for (int i=0. ‘f’}. void main ( ) { for (int i = 0.h> void main ( ) { int even [3] = {0. ‘c’. } // try out // Program .h> # include <conio.

do { cout << ‘\t’ << x [i] << ‘\t’ << y [i] << ‘\t’ << result [i]<<‘\n’. result [5] = { 0.// try out //Program .2.0.5}.4 # include <iostream. i++. i = 0.0. } ªõOf´: The contents of the array are: 1 -1 0 2 4 -2 3 3 0 4 2 2 5 1 4 130 .4. while (i++ < 5) result [i] = x [i] .4.1}. getch ( ).3. } while (i<5).5. cout << “\n The contents of the array are: \n”. int i= 0.h> # include <conio.0.0 }.3.y [i].2.h> void main ( ) { int x[5] = {1. clrscr ( ). y [5] = {5.

cout << “\n Elements after insertion \n”. getch(). for (i= 0. Þ„ªêò™ð£´ õK¬êò£‚è‹ (sorting) âùŠð´Aø¶.h> void main() { int vector[] = {2. (ii) char vowels [ ] = { ‘a’. (i) char name [10].h> # include <conio. ‘u’}. vector [2] = 6. i<5. ‘o’. for(int i=4. i—) vector [i]= vector[i-1].3 êóƒèœ (Strings) êóƒèœ. i++) cout << vector[i].//Try out //Program .5 # include <iostream. 131 . } ªõOf´: Elements of array before insertion 248810 Elements after insertion 246810 æ˜ ÜEJ½œ÷ îó¾è¬÷ ãÁºèñ£è Ü™ô¶ Þøƒ°ºèñ£è õK¬êŠð´ˆî º®»‹. i>2. 8. 0}. â‡õ¬è ÜEè¬÷ ÜPMŠð¶ «ð£¡«ø êóƒè¬÷ ÜPM‚è º®»‹. 10.5. ܬõ å¼ðKñ£í char ÜEò£è‚ è¼îŠð´A¡øù. ‘e’. (iii) char rainbow[ ] = “VIBGYOR”. 5. ‘i’. ñFŠ¹¼‚èœ (literals) âù¾‹ ܬö‚èŠð´A¡øù. â´ˆ¶‚裆ì£è. cout << “\n Elements of array before insertion \n”. clrscr(). 4. i<5. for (i= 0. i++) cout << vector[i].

” << address. cin >> name.”.™ àœ÷¶ «ð£¡ø å¼ char ÜE¬ò„ êóñ£è‚ ¬èò£÷ «õ‡´ªñQ™ Üî¡ ÞÁF àÁŠð£è ‘\0’(NULL) °P»¼¬õ‚ °PŠHì «õ‡´‹.6 // Reading values into an array of characters # include <iostream.. gets(). name. 7.. address. cout << “\n Enter pincode .. cout << “\n Enter name . gets (address). address [30]. cout << “\n Hello “ << name.h> # include <stdio. getline() ÝAòõŸP¡ Íô‹ ªðøŠ ð´A¡øù. clrscr().”.”.h> # include <string.5. cin >> name. ªõŸÁ ÞìªõO Ü™ô¶ ï蘈F F¼‹ð¬ô (Carriage Return . cout << “\n Pincode .. cin.... pincode[7]. cout << “\n Your address is .. cin. cout.Enter Key) êóˆF¡ ߟø£è â´ˆ¶‚ ªè£œÀ‹. char name [30].6).getlin e (pincode.h> void main() { clrscr().5. getch(). 132 . (iii) ÝAòõŸP™ àœ÷¶«ð£ôˆ ªî£ì‚è ñFŠH¼ˆF ÜPM‚èô£‹. } «ñŸè‡ì â´ˆ¶‚裆®™ (Program . // Program .. pincode ÝAò ñ£PèÀ‚è£ù ñFŠ¹èœ cin.”..å¼ char ÜE¬ò (ii).h> # include <conio.write(pincode. (ii). â´ˆ¶‚裆ì£è.’#’). sizeof(pincode)). cout << “\n Enter address..

N. write() â¡ð¶ Ü®Šð¬ì ªõOf†´ˆ ó Üî£õ¶ ostream.h> void main() { clrscr().Perumal âù àœk´ î‰î£™. cout << ‘\n’.äŠ ðò¡ð´ˆî «õ‡´‹.V.7 # include <iostream. 7). char name[ ] = “Tendulkar”. æ˜ Þù‚°¿M¡ ܬùˆ¶ àÁŠ¹„ ªêòŸ ÃÁè¬÷»‹. cout.write (pincode. name-™ Ý) K.¡ ñFŠð£è K.write (name. name.5.ä Ü´ˆ¶ æ˜ ÞìªõO MìŠð†ì ܶ«õ êóˆF¡ ߟø£è â´ˆ¶‚ ªè£œ÷Šð´‹.Ü) àœkì£è K V N Perumal âù‚ ªè£´ˆî£™. } getch(). Ü™ô¶ Ü®Šð¬ì àœk†´ˆ ó istream. êóˆF¡ àœ÷ì‚èˆ¬îˆ F¬óJ™ 裆ì Þó‡´ õNº¬øèœ àœ÷ù: 1. stdio. } 133 .Perumal â¡ø º¿Šªðò¼‹ Þ¼ˆîŠð´‹.¡ àÁŠ¹„ ªêòŸÃø£ù getline(). while (i<10) { cout. i).getline(char *. int i=1.Hø ñ£PèO¡ ñFŠ¬ð ªõOJ´õ¬îŠ «ð£¡ø«î 2. â´ˆ¶‚裆´: //Program .write (pincode. . write() ªêòŸÃP‚°ˆ «î¬õò£ù Þó‡´ Ü÷¹¼‚èœ êóˆF¡ ªðò˜.¡ àÁŠ¹„ ªêòŸÃø£°‹.™ K ñ†´«ñ Þ¼ˆîŠð†®¼‚°‹. êó ñFŠH¡ ܃èñ£è ÞìªõOè¬÷»‹ â´ˆ¶‚ªè£œ÷ «õ‡´ ªñQ™. Ü™ô¶ cout. ܉î Þù‚°¿M™ à¼õ£‚èŠð†ì æ˜ ÞùŠªð£¼O¡ (object/instance) Íôñ£è Üμè «õ‡´‹. 裆ìŠðì «õ‡®ò ⿈¶èO¡ â‡E‚¬è. i++.h> # include <conio.N. cout <<name.V. ⿈¶èO¡ â‡E‚¬è. name. õ󋹂°P). è†ì¬÷ò¬ñŠ¹: gets() : gets(char ÜEJ¡ ªðò˜) Ü™ô¶ gets (char *) getline() : cin. sizeof(pincode)).h â¡Â‹ «è£ŠH™ õ¬óòÁ‚èŠð†´œ÷ gets() â¡Â‹ ªêò™ÃP¬ùŠ ðò¡ð´ˆî «õ‡´‹. è£óí‹ K.

´) strcpy(name. (â-´) strcmp (“Abc”. êóƒè¬÷‚ ¬èò£À‹ ªêòŸÃÁèO¡ M÷‚般î ܆ìõ¬í 5. Íô„ êóˆ¬î Þô‚°„ êóˆF™ char*) ð®ªò´‚°‹ (â.´): char name[ ] = “Lasya”.h «è£ŠH™ õ¬óòÁ‚èŠð†´œ÷. “Abc”) â¡ð¶ 0 â¡Â‹ M¬ì . ܆ìõ¬í 5. êó„ ªêòŸÃÁèœ 134 . Þó‡´ êóƒè¬÷ åŠH†´. petname) 3 strcmp() strcmp(char*. strcmp ( “abc”. 0 â¡ø M¬ì¬òˆ . H¡¹ Þ¼ŠH¡ 1 â¡ø M¬ì A¬ì‚°‹. char*) Þó‡´ êóƒèÀ‹ Gè˜ âQ™.1-™ 裇è: õK¬ê ªêòŸÃÁ è†ì¬÷ ⇠ܬñŠ¹ strlen() strlen(char*) 1 ðò¡ð£´‹ F¼ŠHòŠ¹‹ ñFŠ¹‹ êóˆF½œ÷ ⿈¶èO¡ â‡E‚¬è¬òˆ . (â. “abc”) â¡ð¶ -1 â¡Â‹ M¬ì. Üèó õK¬êŠð® ºî™êó‹ Þó‡ì£õ¶ ê󈶂° º¡¹ Þ¼ŠH¡1â¡Â‹ M¬ì¬òˆ .1. strcmp (“Abc”.5 â¡ø M¬ì¬òˆ . 2 strcpy() strcpy(char *.ªõOf´: T Te Ten Tend Tendu Tendul Tendulk Tendulka Tendulkar string. “Abc”) â¡ð¶ 1 â¡Â‹ M¬ì . strlen(name).

. cout << ‘\n’.5. while (i>= 0) reverse [i—] = name [j++]. } W›‚è£μ‹ GóL¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? //Program .8 # include <iostream.h> # include <string. j = 0.h> # include <conio. char name[] = “Pascal”.5. int i=0. int j = 0. while (i < 4) { j = 0..9 # include <iostream.h> void main() { clrscr(). getch(). } 135 . int i= 0. —i. reverse[7].h> main() { char word[] = “test”. i++. cout << “\n The contents of the reversed string . cout << “\n The contents of the string are: “<< name. reverse[i] = ‘\0’. k = 4. while (j<=i) cout << word [j++].êóƒè¬÷ æ˜ å¼ðKñ£í char ÜE «ð£ô«õ åš«õ£˜ ⿈î£è â´ˆî£÷ º®»‹. } return 0. while (name[i] != ‘\0’) i++. clrscr().” << reverse. â´ˆ¶‚裆´: // Program .h> # include <conio.

marks [0] [3] = marks[0] [0] + marks[0] [1] + marks[0] [2]. 80.2 1. 75.2 0. 70.0 1.4. √ ÜE àÁŠ¹è¬÷‚ °P‚°‹ Wªö£†´èœ (subscripts) ⊫𣶫ñ 0-M™ ªî£ìƒ°A¡øù.1 0. â´ˆ¶‚裆ì£è.2 2. â´ˆ¶‚裆ì£è.3 int marks[3] [4] = {90.1 1. °PŠ¹: √ æ˜ Þ¼ðKñ£í ÜEJ¡ àÁŠªð‡E‚¬è. 65. 136 . «ñ«ô è‡ì â´ˆ¶‚裆®™ marks â¡Â‹ ÜE 12 (3x4) àÁŠ¹è¬÷‚ ªè£‡´œ÷¶. ºî™ A사èJ½œ÷ ñFŠªð‡è¬÷. Þ¼ðKñ£í ÜE (Two-Dimensional Array) Þ¼ðKñ£í ÜE â¡ð¶. 90. 90. 3 A사èèœ. √ Þ¼ðKñ£í ÜEJ¡ àÁŠ¹ marks[ A사è] [ ªï´‚¬è] âù‚ °PŠHìŠð´‹.0 2. 95. Üî£õ¶ 90. 70. 0. 80.1 2. å¼ðKñ£í ÜEè¬÷ àÁŠ¹è÷£è‚ ªè£‡ì æ˜ ÜEò£°‹.3 2.0 0. A사è/ªï´‚¬è â‡E‚¬èèO¡ ªð¼‚°ˆ ªî£¬èò£°‹. 0.5. ªï´‚¬èèÀ‚° 0 ºî™ 3 õ¬ó»‹ Þ¼‚°‹. 0 1 2 3 0 90 70 80 0 1 75 95 65 0 2 80 90 90 0 â¡Â‹ ܆ìõ¬í¬ò à¼õ£‚°‹. 4 ªï´‚¬èèœ ªè£‡ì æ˜ Ü†ìõ¬í¬ò‚ °P‚°‹. marks[3] [4] â¡Â‹ ÜE. â¡Â‹ è†ì¬÷. 0}. 0. 80 ÝAòõŸP¡ Æ´ˆ ªî£¬è¬ò‚ èí‚A´‹. A사èè¬÷‚ °P‚°‹ Wªö£†´ 0 ºî™ 2 õ¬ó»‹. â¡Â‹ Þ¼ðKñ£í ÜE.3 1.

3 ªï´‚¬èèœ ªè£‡ì¶.fine â¡Â‹ Þ¼ðKñ£í ܆ìõ¬í 65 A사èèœ. short fine [‘A’] [‘E’] . int ñ£PLèœ 2. char ñ£PLèœ 4. àÁŠ¹èO¡ ñFŠ¹èœ W›‚è£μ‹ º¬øèœ å¡P™ Þ¼ˆîŠð´A¡øù.major) â¡Á ªðò˜ 2. cons int i = 5.a â¡Â‹ ÜE 3 A사èèœ. A사è õ£Kò£è: A사è . . 2.major) â¡Á ªðò˜ 137 .4. 69 ªï´‚¬èèœ ªè£‡ì¶. float num [i] [3].æ˜ Þ¼ðKñ£í ÜE Þšõ£Á ÜPM‚èŠð´Aø¶: < îóMù‹ > < ÜEŠªðò˜> [< A사è>] [< ªï´‚¬è>]. °PŠ¹: ÜEJ¡ ðKñ£íƒèœ (A사èèœ/ªï´‚¬èèœ) Þšõ£ªø™ô£‹ Þ¼‚è º®»‹: 1. Þ¼ðKñ£í ÜEèO¡ G¬ùõè Þ¼ŠHì‹ æ˜ Þ¼ðKñ£í ÜEJ¡ àÁŠ¹èœ G¬ùõèˆF™ ªî£ì˜„Cò£ù Þ¼ŠHìƒèO™ Þ¼ˆF¬õ‚èŠð´A¡øù. enum °PŠªðò˜èœ 5. 1. º¿â‡ Ü™ô¶ õK¬êªò‡ ꣘‰î ñ£PL‚ °PŠªðò˜èœ 3. ªï´‚¬è õ£Kò£è: ªï´‚¬è .ºî¡¬ñ (row . 2 ªï´‚¬èèœ ªè£‡ì¶.num â¡Â‹ Þ¼ðKñ£í ܆ìõ¬í 5 A사èèœ. 3. â´ˆ¶‚裆´: 1. int a[3] [2] .ºî¡¬ñ (column .1.

1 2-õ¶ ªï´‚¬è 1. ªï´‚¬è .â´ˆ¶‚裆´: int sales[2][4] â¡ø ÜEJ¡ àÁŠ¹èœ Þšõ£Á ܬñA¡øù: A사è-ºî¡¬ñ õK¬ê 0.ºî¡¬ñ õK¬ê 0.3 ªï´‚¬è .3 sales[1][0] â¡ø àÁŠH¡ Þì Þ¼Š¬ð‚ A사è-ºî¡¬ñ õK¬êJ½‹.0 0.3 1.1 2-õ¶ A사è 1.0 0.0 1.2 1.1 0.2 0.2 0.2 3-õ¶ ªï´‚¬è 1.ºî¡¬ñ õK¬êJ½‹ èõQˆb˜è÷£? 138 .3 4-õ¶ ªï´‚¬è 1.1 1-õ¶ A사è 0.0 1-õ¶ ªï´‚¬è 1.

4. 5. 9. num 0 1 2 0 8 7 6 1 4 5 8 2 3 9 1 7 2 6 3 num ܆ìõ¬íJ™ õ†ìIìŠð†ì ñFŠ¹èO¡ àÁŠ¹è¬÷ â¿F‚ 裆´è: 139 . 3}. 8. 7. 6. 7. 6. â´ˆ¶‚裆ì£è.Þ¼ðKñ£í ÜEJ¡ G¬ùõè‚ ªè£œ÷÷¾ Þšõ£Á èí‚AìŠð´Aø¶: àÁŠªð‡E‚¬è x æ˜ àÁŠ¹‚°ˆ «î¬õò£ù G¬ùõè Ü÷¾. 2. 1. int sales[2][4] â¡ø ÜEJ¡ Ü÷¾ Þšõ£Á èí‚AìŠð´Aø¶: àÁŠªð‡E‚¬è = A사èèœ x ªï´‚¬èèœ = 2 x 4 = 8 ç 8 x 2 (æ˜ int ñFŠ¹‚° 2 ¬ð†´èœ) ç Ü÷¾ = 16 ¬ð†´èœ float num [4][6] â¡ø ÜEJ¡ Ü÷¾ â¡ùõ£è Þ¼‚°‹? M¬ì : 4 x 6 x 4 = 96 ¬ð†´èœ W›‚è£μ‹ ÜE¬ò «ï£‚°è: int num[4][3] = {78.

(2) W«ö ÜPM‚èŠð†´œ÷ ÜEèO™. è£óí‹.(9) num[3][1] . å¼ ºèõK¬ò º¬øò£ù Ü÷¹¼¾‚° ÜŠH ¬õ‚A«ø£‹ â¡Á ªð£¼œ (°PŠ¹õ¬è Ü÷¹¼¬õŠ «ð£ô). ÜEJ¡ ªðò¬ó ñ†´‹ ªñŒò£ù Ü÷¹¼õ£è‚ °PŠH†ì£™ «ð£¶‹. ÜEJ¡ ªðò˜. ðKñ£íƒè¬÷‚ °PŠHìˆ «î¬õJ™¬ô. ªêò™ÃÁèÀ‚°. 2.M¬ì: num[0][1] . 3} M¬ì : 6 àÁŠ¹èœ (A사è-3. G¬ùõèˆF™ ÜšõE Þ¼ˆîŠð†´œ÷ ð°FJ¡ ªî£ì‚è ºèõK¬ò‚ °P‚Aø¶. 140 . ÜEè¬÷„ ªêò½¼¹è÷£è ÜŠH¬õ‚è º®»‹. âù«õ ÜEJ¡ ªðò¬ó ªêò½¼ð£è‚ °PŠH´õ¶. 2. ºî™ ðKñ£íˆ¬î‚ °PŠH´õ¶ è†ì£òI™¬ô. ÜE Ü÷¹¼‚èœ Þò™ð£è«õ °PŠ¹õ¬è Ü÷¹¼‚èœ «ð£ô„ ªêò™ð´A¡øù. ªï´‚¬è-2) ªî£ì‚è ñFŠ¹è«÷£´ ÜE¬ò ÜPM‚°‹«ð£¶.(7) num[1][1] . Hø ñ£P èO¡ ªðò˜èœ Üšõ£P™¬ô. 1. 1. àÁŠ¹èO¡ â‡E‚¬è¬òˆ b˜ñ£Q‚辋: Ü) int array[10] [12]. M¬ì : 120 àÁŠ¹èœ Ý) int x[ ] [2] = {0.(5) num[2][0] .

”. } } } void display (int d[3][4]. for (c = 0. } 141 . c. int sales[3][4].”. r < 3.” << total.5. accept(sales. c < 4.10 #include <iostream.h> void accept (int s[3][4].. c ++) cout << ‘\t’ << d[r][c].” << r+1.t). for (c = 0.. } cout << “\n Total sales . r++) { cout << “\n Month .. r < 3.// Program . c < 4. } void main() { clrscr(). int &total) { int r = 0. r++) { cout << “\n Month: “ << r+1.t). total += s[r][c]. clrscr ( ).h> # include <conio. display(sales. for (r = 0. getch(). cout << “\nSales figures for 3 months & their respective quarters. int total) { int r. c++) { cout << ‘\n’ << c+1 << “ Quarter... cin >> s[r][c]. t = 0. c = 0. for (.

4 ÝAò ñFŠ¹èœ îóŠð´õî£è‚ ªè£œè. getch(). c < 2. clrscr(). c++) display (num[r][c]). for (r = 0.. c = 0. 142 . r < 2. clrscr ( ). 4 ÝAò ñFŠ¹èœ ã¡ Þ¼ˆîŠðì M™¬ô âù â‡EŠ 𣘈b˜è÷£? Þ‰î â´ˆ¶‚裆®™.h> void accept(int a) { cout << “\n Enter a number .0}}.5.h> # include <conio. } void display(int a) { cout << ‘\n’ << a.0}. r++) for (.{0. 2. âù«õ.”. r++ ) for (c = 0. ܬõ ñFŠ¹ õ¬è Ü÷¹¼õ£è«õ â´ˆ¶‚ ªè£œ÷Šð´‹.11 # include <iostream. } accept() ªêò™ÃP‚° àœkì£è 1. M¬ì: 0 0 0 0 âù‚ A¬ì‚°‹. c < 2. num ÜEJ¡ àÁŠ¹èO™ 1. °PŠ¹õ¬è Ü÷¹¼õ£è‚ è¼F‚ ªè£œ÷Šð죶. 3. } void main() { int num [2][2] ={{0. 2. 3. r < 2. void accept() ªêò™ÃP‚° Ü÷¹¼õ£è îQˆîQ àÁŠ¹èœ ÜŠH¬õ‚èŠ ð´A¡øù. for (. r = 0.ÞŠ«ð£¶ W«ö»œ÷ Gó¬ô «ï£‚°è: // Program . c++) accept(num[r][c]). cin >> a.

«ñŸè‡ì GóL™ accept() ªêò™ÃP¬ù„ ꟫ø ñ£ŸP â¿î «õ‡´‹. 5. “Friday”. 5. Þó‡ì£õ¶ ²†ªì‡ (ªï´‚¬è â‡E‚¬è) êóƒèO¡ à„ê Ü÷¾ c÷ˆ¬î‚ °P‚°‹. ÜE‚«è£¬õè¬÷ Þ¼ðKñ£í ÜEè÷£è õ¬óòÁ‚è º®»‹. 4 âù Ü«î àœk´è¬÷ˆ .2. ÜE õ¬óòÁŠH™ àœ÷ ºî™ ²†ªì‡ (A사è â‡E‚¬è) êóƒèO¡ â‡E‚¬è¬ò‚ °P‚°‹. “Saturday”}. ªõOfì£è.1-Þ™ àœ÷õ£Á Þ¼ˆîŠð†®¼‚°‹.5. êóƒèO¡ ÜE êóƒèO¡ ÜE â¡ð¶ æ˜ Þ¼ðKñ£í char ÜE Ý°‹. Program-5. 1. 3. 1 2 3 4 âùŠ ªðøº®»‹. 2. “Thursday”. Þ‰î ÜEJ¡ àÁŠ¹èO½œ÷ ñFŠ¹èœ ܆ìõ¬í 5.4. “Wednesday”. ÜE‚«è£¬õ (Matrix) ÜE‚«è£¬õ â¡ð¶ m x n â‡è¬÷ m A사èèO½‹ n ªï´‚¬è èO½‹ å¼ ªêšõè ÜE õ®M™ ªè£‡®¼‚°‹.12 Gó™ Þó‡´ ÜE‚«è£¬õèÀ‚è£ù ñFŠ¹è¬÷ àœkì£èŠ ªðŸÁ ÜšõE‚ «è£¬õèO¡ G蘊𣆬ì (equality) ðK«ê£Fˆ¶ M¬ì î¼Aø¶.°PŠ¹: ÜEJ¡ ªðò˜ ñ†´«ñ ÜEJ¡ ªî£ì‚è ºèõK¬ò‚ °P‚Aø¶. “Monday”. â´ˆ¶‚裆´: char day-names [7] [10] = {“Sunday”. ÞŠ«ð£¶. “Tuesday”. 143 .

for (. i < 3. accept (m1). break. int r = 0. int i=0. } } void main() { int m1[3][3].. j < 3. c++) cin >> mat[r][c].”.5. accept (m2). } 144 . r++) { cout << “\n Enter elements for row. } if (flag) cout << “\n The matrices are equal . else cout << “\n The matrices are not equal. for (.h> void accept(int mat[3][3]) { clrscr(). i++) { for (.12 # include <iostream.//Program . } if (flag == 0) break. j = 0.. j ++) if (m1[i][j] != m2[i][j]) { flag = 0.. r < 3. m2[3][3]. c = 0.h> # include <conio. getch()..” << r. flag = 1. c < 3. for (c=0.”.

eF àÁŠ¹ èO™ 0 ñFŠ¹ î£ñ£è«õ Þ¼ˆîŠð†´M´‹.Þ¶ H¬ö ²†ì£¶.0}.0. Þ) float num[A]. . 嚪õ£¼ êóˆF¡ ÞÁFJ½‹ ªõŸÁ‚ °P»¼¬õ„ (null character .1 G¬ùõèˆF™ ÜEJ¡ àÁŠ¹èœ ÜEJ½œ÷ îQˆîQ„ êóƒè¬÷‚ ¬èò£÷ day-names[0] âù ºî™ ²†ªì‡ (A사è â‡) ñ†´‹ °PŠH†ì£™ «ð£¶‹.5]. Þšõ£Á °¬øõ£è Þ¼‚°ªñQ™. Ý) float f[3] = {1. . W›‚è£μ‹ è†ì¬÷èœ H¬ö²†´õ¶ ã¡? Ü) int a[5. å¼ êóˆF½œ÷ å¼ °PŠH†ì ⿈¬î Üî£õ¶ ÜEJ¡ å¼ îQ àÁŠ¬ð‚ ¬èò£÷ day-names[0][5] âù Þó‡´ ²†ªì‡è¬÷»‹ (A사è/ªï´‚¬è â‡è¬÷) °PŠHì «õ‡´‹. 145 . Ýù£™ ÜEJ™ °PŠHìŠð†´œ÷ àÁŠ¹ â‡E‚¬è¬òMì‚ °¬øõ£ù ñFŠ¹è«÷ îóŠ ð†´œ÷ù. ðJŸC Mù£‚èœ 1.  «ê˜‚è£M†ì£½‹ C++ Gó™ªðò˜ŠH î£ù£è«õ ެ툶‚ ªè£œÀ‹. 2.ÜEJ¡ ðKñ£í‹ º¿â‡í£è«õ Þ¼‚è«õ‡´‹.‘\0’) «ê˜Šð¶ è†ì£òI™¬ô (optional).0 1 2 3 4 5 6 0 S M T W T F S 1 u o u e h r a 2 n n e d u i t 3 d d s n r d u 4 a a d e s a r 5 y y a s d y d 6 \0 \0 y d a \0 a 7 8 \0 a y y \0 y \0 9 \0 day-names [0] day-names [1] day-names [2] day-names [3] day-names [4] day-names [5] day-names [6] ܆ìõ¬í 5.

strcpy(test. âù ÜPM‚è «õ‡´‹. . . 146 . Þó‡ì£õ¶ ðKñ£í‹ è†ì£òñ£è Þ싪ðø «õ‡´‹. float num[A].æ˜ ÜEJ™ Þšõ£Á ñFŠH¼ˆî º®ò£¶. “two”. const A=10.. Ü™ô¶. âù ñ£ŸP â¿îô£‹. char a[ ] [6] = {“one”. ÞF™. âù ÜPM‚èô£‹. Ü™ô¶ char ÜEò£è«õ ÜPM‚è «õ‡´ªñQ™. char ch[1] = {‘s’}. test = {“abc”}. float num[‘A’] Ü™ô¶. -char ÜE¬ò êóñ£è ÜPM‚è «õ‡´ªñQ™. âù ñ£ŸP â¿îô£‹. á) char test [4]. ނ߬ø«ò. âù«õ «ñŸè‡ì ߬ø. “abc”). ÜPM‚°‹«ð£«î ªî£ì‚è ñFŠH¼ˆF. ß) char a[3] [ ] = { “one”. à) char ch[1] = ‘s’. âù‚ °PŠHìô£‹. char test [4]. char test[4] = “abc”. êó ñ£PJ™ ð®ªò´‚èô£‹. “three”}.ÜEJ¡ ðKñ£í‹ ªõOŠð¬ìò£è ÜPM‚èŠðì «õ‡´‹. char ch[2] = “s”. “three”}. âù„ êóñFŠ¬ð. “two”.ªî£ì‚è ñFŠ¹ì¡ ÜPM‚èŠð´‹ æ˜ Þ¼ðKñ£í ÜEJ™ ºî™ ðKñ£íˆ¬î M†´Mìô£‹. A â¡Â‹ ñ£P‚° ñFŠ¹ ⶾ‹ A¬ìò£¶.

cout << num [1]. 2. M¬ìèœ: Ü) rate [0] = 30. num2[10]. num3[15]. Þ) char product-list [ ] [5] = { “Nuts”.roaster â¡Â‹ ñ£P å«óªò£¼ ñFŠ¬ð«ò 㟰‹.3. åš«õ£˜ àÁŠð£è«õ ¬èò£÷ º®»‹. ã) int num[3]. 40. .2. -ÜEè¬÷‚ °¿õ£è ÜPMˆ¶ ñFŠH¼ˆî õNJ™¬ô. ch[0] = ‘C’.3}. Ý) char ch[b] = {“bbbbb\0”}. cin >> num. W›‚è£μñ£Á ªî£ì‚è ñFŠH¼ˆîŠð†ìH¡ ÜEJ¡ àœ÷ì‚è‹ â¡ùõ£è Þ¼‚°‹? Ü) int rate[ ] = {30. int num1[5].4} . Ü™ô¶. âù ܬñ‚èô£‹. rate[2] = 50 147 . ch[3] = ‘A’. “Screw”}. num2 = num. 50}. ch[4] = ‘T’.Þ¶ «ð£¡ø ÜE àœk†´/ ªõOf†´„ ªêò™ð£´èÀ‚° ÜÂñFJ™¬ô. int roaster = 10. int roaster [ ] = {1.2. num2[3]. âù ªõÁñ«ù °¿õ£è ÜPM‚èô£‹. rate[1] =40. cout << num. “Bolts”.2.â) int num[ ] = {1.4}. cin >> num[2]. ä) int roaster = { 1. âù ܬñ‚èô£‹. ªî£ì‚è ñFŠH¼ˆî½‹ ªêŒò «õ‡®J¼ŠH¡ îQˆîQ«ò ªêŒò «õ‡´‹. -b â¡ð¶ ÞìªõO¬ò‚ °P‚Aø¶.3. âù«õ. .

4. } M¬ì: ÜEJ¡ ªî£ì‚è àœ÷ì‚è‹: a[0] = 1. ch[5] = ‘\0’ Þ) product-list[0] = “Nuts\0”. a[2] = 3.Ý) ch[0] = ‘C’. ch[3] = ‘A’. for (int i = 0.2. 3. a[1] = 2.h> void main ( ) M¬ì: END { char ch [ ] = “END”. W›‚è£μ‹ Gó™èO¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? Ü) # include <iostream. i++) a[i+1] = a[i].h> void main ( ) { int a [ ] = {1. ch[4] = ‘T’. ch[1] = ‘ ’. product-list[2] = “Screw\0”. cout << ch. } Ý) # include <iostream.5}. a[3] = 4. i = 0 : a[1] = a[0] i = 1 : a[2] = a[1] i = 2 : a[3] = a[2] i = 3 : a[4] = a[3] 148 . for (i= 0. product-list[1] = “Bolts\0”.3. i<5. ch[2]= ‘ ’. i < 4. a[4] = 5 ºî™ for() ñì‚° ªêò™ð´‹ «ð£¶. i++) cout << ‘\n’ << a[i].

Þ) # include <iostream. 20. for (int i = 0. 40. âù«õ. Gó™èœ ⿶è: 1) int . i = 2 : k = 3.h> void main( ) { char name[ ] = “Jerry”. i < 3. ªõOf´. name[3] = name[2]. 4.array â¡Â‹ æ˜ int ÜE¬ò 10. 30. name[4] = name[1]. cout << name. 50 ÝAò ªî£ì‚è ñFŠ¹èÀì¡ õ¬óòÁ‚辋. ªõOf´. i = 1 : k = 4. getch( ). k —) name [k] = name[i].âù«õ. Þ‰î ÜE àÁŠ¹èO¡ ñFŠ¹è¬÷‚ Æ® M¬ì¬ò‚ 裆쾋. JerreJ âù‚ A¬ì‚°‹. i = 0 : k = 5. } M¬ì: for() ñì‚° ªêò™ð´‹«ð£¶. int k=5. name[5] = name[0]. i ++. 1 1 1 1 1 âù ܬñ»‹.h> # include <conio. 149 .

Þó‡´ ÜE‚«è£¬õ è¬÷»‹ Æ® sum-matrix[4][4] â¡Â‹ ÜE‚«è£¬õJ™ Þ¼ˆF.2) 10 ñFŠ¹è¬÷ Þ¼ˆF¬õ‚è îò æ˜ int ÜE¬ò ÜPM‚辋. 3) word â¡Â‹ êó ñ£PJ™ (char ÜE) ðòùKìI¼‰¶ å¼ ªê£™ªî£ì¬óŠ ªðŸÁ Þ¼ˆ¶è. char word[ ] = “The Vowel count AEIOU aeiou”. Üî¡ àœ÷ì‚èˆ¬î ªõOJ´è. Ü‹ñFŠ¹è¬÷ º¡H¡ õK¬êJ™ F¬óJ´è. Vowel count is 14 4) MATRIX[3][3] â¡Â‹ ÜE‚«è£¬õ¬ò à¼õ£‚辋. 5) matrixA [4][4]. ͬôM†ì àÁŠ¹èO¡ ñFŠ¹è¬÷»‹ ÜõŸP¡ Æ´ˆ ªî£¬è¬ò»‹ ªõOJ´è. â´ˆ¶‚裆ì£è. ÜEJ¡ àÁŠ¹èÀ‚°Š ðòùKìI¼‰¶ ñFŠ¹è¬÷Š ªðÁè. matrixB [4][4] ÝAò Þ¼ ÜE‚«è£¬õèÀ‚° ñFŠ¹è¬÷ àœkì£èŠ ªðÁè. â´ˆ¶‚裆´: matrixA matrixB sum-matrix 1234 5678 9876 5432 10 10 10 10 10 10 10 10 9123 4567 1987 6543 10 10 10 10 10 10 10 10 150 . while() ñì‚° switch() ßÁ ÝAò¬õ ðò¡ð´ˆFˆ ªî£ìK½œ÷ àJªó¿ˆ¶è¬÷‚ (vowels) èí‚A†´ M¬ì¬ò ªõOJ´è.

com Location: Commercial Taxes Staff Training Institute. student Þù‚°¿¬õ «ñ½‹ MK¾ð´ˆî º®»‹.2 Þù‚°¿¬õ õ¬óòÁˆî™ æ˜ Þù‚°¿M¡ õ¬óòÁŠ¹ Þ¼ð°Fè¬÷‚ ªè£‡ì¶: 1) Þù‚°¿ ÜPMŠ¹ 2) Þù‚°¿M¡ ªêòŸÃÁ õ¬óò¬øèœ 151 . int rollno.Ramanathan Digitally signed by Ramanathan DN: cn=Ramanathan. total_marks.. C++ ªñ£N¬ò à¼õ£‚Aò «ü¡ v†ªó÷v†óŠ î‹ ªñ£N‚° ºîL™ ‘Þù‚°¿¾ì¡ îò C’ (C with Classes) â¡Á ªðò˜ ņ®ù£˜ â¡Aø îèõ™. marks2. ²¼ƒè‚ ÃP¡.Ph:9442282076 Date: 2008. } «ñŸè‡ì Þù‚°¿M™ ÜPM‚èŠð†´œ÷ rollno. Þ‰îˆ îó¾è¬÷‚ ¬èò£÷‚ îò ªêòŸÃÁè¬÷ õ¬óòÁˆ¶. îó¾ èO¡ e¶ Gè›ˆî‚ Ã®ò ð™«õÁ ªêò™ð£´è¬÷ (îó¾ ñFŠ¹è¬÷ àœkì£è ªðÁî™.1 Þù‚°¿‚èœ .03. marks1. marks1. class student { char name[30]. Computer Lecturer. ou=Computer Lecturer. îó¾è¬÷»‹ ÜõŸ«ø£´ ªî£ì˜¹¬ìò ªêòŸÃÁè¬÷»‹ å¡ø£è„ «ê˜ˆ¶¬õ‚è Þù‚°¿ õ¬è ªêŒAø¶. «õÁð†ì Þùˆîó¾è¬÷ å¡ø£è„ «ê˜ˆ¶¬õ‚è Þù‚ °¿‚èœ å¼ ¹Fò õNº¬ø¬ò õöƒ°A¡øù. Þù‚°¿M¡ º‚Aòˆ¶õˆ¬î â´ˆFò‹¹Aø¶..13 11:58:51 +05'30' ð£ì‹ 6 Þù‚°¿‚èÀ‹ ªð£¼œèÀ‹ (Classes and Objects) 6. marks2.å¼ º¡Â¬ó C++ ªñ£NJ¡ Iè º‚Aòñ£ù ð‡¹‚ÃÁ ‘Þù‚°¿’ â¡ð‹. email=ctdsti@gmail. 6. c=IN. o=Commercial Taxed Dept Staff Training Institute. ðòù˜ õ¬óòÁ‚°‹ îóMùƒèÀœ ‘Þù‚°¿’ â¡ð¶. è£óí‹. Þˆî¬èò ªêòŸÃÁè¬÷ õNº¬øèœ (methods) â¡Á‹ ÃÁõ˜. ðòù˜èœ ¹Fò îóMùƒè¬÷ à¼õ£‚辋 ï¬ìº¬øŠð´ˆî¾‹ å¼ ¹Fò õN¬òˆ Fø‚Aø¶. total_marks ÝAò îó¾ ñ£Pèœ student â¡Â‹ ÞùˆF¡ ð‡¹‚ÃÁè¬÷ ªõOŠð´ˆ¶A¡øù. îó¾èœ ðƒ°ªðÁ‹ èí‚W´èœ «ð£¡ø¬õ) ܬõ õ¬óò¬ø ªêŒA¡øù.

h> # include <conio. “<<marks2.// Program . display(). } }.execute(). cout<<“\n Constructor executed . rollno=marks1=marks2=total_marks=0. cout<<“\n Total Marks. roll no.h> class student { private : char name[30].. compute(). marks 1 and marks 2.1 # include <iostream.. student stud. “<< total_marks. int rollno.... marks2 . } void display() { cout<<“\n Name “<<name. cin>>name>>rollno>>marks1>>marks2. “. “<<marks1. void main() { clrscr().total_marks. cout<<“\n Roll no “<<rollno. protected: void accept() { cout<<“\n Enter data name. } void execute() { accept(). cout<<“\n Marks 2. } 152 . marks1.. stud. cout<<“\n Marks 1. “. } public: student() { name[0]=’\0'.6. } void compute() { total_marks = marks1+ marks2.

marks1. int rollno. public: student( ). protected: variable decl. Þù‚°¿M¡ àìŸð°F ñ£Pèœ ñŸÁ‹ ªêòŸÃÁèO¡ ÜPMŠ¹è¬÷‚ ªè£‡´œ÷¶. }. ܉î Þù‚°¿M¡ Ü®Šð¬ìJ™ î¼M‚èŠð†ì Þù‚°¿¾‚°œÀ‹ â´ˆî£÷ º®»‹.  Þù‚°¿M¡ àìŸð°F ªïO¾ ܬ승‚ °Pè÷£™ Üì‚èŠð†´ æ˜ Ü¬óŠ¹œO»ì¡ ºŸÁŠ ªðÁAø¶. public: variable decl.     private â¡Â‹ ÜμAò™¬ð‚ °PŠH´õ¶ è†ì£òI™¬ô. function decl. private âù ÜPM‚èŠð†ì àÁŠ¹è¬÷ ܉î Þù‚°¿¾‚°œ«÷  Üμè º®»‹. protected: void accept( ). protected âù ÜPM‚èŠð†ì àÁŠ¹è¬÷ ܉î Þù‚°¿¾‚°œÀ‹. Þù‚°¿M¡ àìŸð°F Í¡Á ÜμAò™¹ õ¬óòÁŠHè¬÷‚ (ªõO‚裆´‹ C†¬ìèœ) ªè£‡´œ÷¶: private. marks2. total_marks.   protected. public. function decl. void execute( ).  class â¡Â‹ CøŠ¹„ ªê£™. 153 .Þù‚°¿ ÜPMŠH¡ õ®õ‹: ªð£¶õ®õ‹ class class-name { private: variable declaration function declaration «ñŸè‡ì â´ˆ¶‚裆®™ àœ÷ Þù‚°¿ õ®õ‹ class student { private. }. âšMî ÜμAò™¹‹ °PŠHìŠðìM™¬ô âQ™ Þù‚°¿M¡ àÁŠ¹èœ Þò™ð£è private â¡«ø è¼F‚ªè£œ÷Šð´‹. void compute( ). Þ¶ ðòù˜ õ¬óòÁ‚°‹ class â¡Â‹ îó¾ Þù‹ â¡ð¬î à혈¶Aø¶. public âù ÜPM‚èŠð†ì àÁŠ¹è¬÷ ܉î Þù‚°¿¾‚° ªõO«ò»‹ â´ˆî£÷ º®»‹. char name [10]. void display( ).

6. Þî¬ùˆ îó¾ ñ¬øŠ¹ (Data Hiding) â¡A«ø£‹. àÁŠ¹èÀ‹ (members) õ󋹂°†ð†ì º¬øJ™ Üμ°ñ£Á 膴Šð£´ MF‚°‹ ¸†ð‹ îó¾ ܼõñ£‚è‹ (Data Abstraction) âùŠð´Aø¶.1. Hø Þù‚°¿‚èO¡ ªð£¼œèÀ‹ (objects). ÜNŠHèœ (destructors) â¡Â‹ îQ„ CøŠð£ù àÁŠ¹„ ªêòŸÃÁè¬÷»‹ ªè£‡´œ÷ù. Þù‚°¿‚èœ Ý‚Aèœ (constructors). 154 . protected Ü«î Þù‚°¿ ñŸÁ‹ Üî¡ î¼M‚èŠð†ì Þù‚°¿‚èO¡ àÁŠ¹è÷£™ Üμè º®»‹. public Ü«î Þù‚°¿M¡ àÁŠ¹èÀ‹ ªð£¼œèÀ‹ ñ†´I¡P ªõO Þù‚°¿‚èO¡ àÁŠ¹è÷£½‹ Üμè º®»‹.4 îó¾ àÁŠ¹èÀ‹ àÁŠ¹„ ªêòŸÃÁèÀ‹ Þù‚°¿ Þ¼õ¬è àÁŠ¹è¬÷‚ ªè£‡ì¶. Program-6. àÁŠ¹„ ªêòŸÃÁèœ â¡ð¬õ æ˜ Þù‚°¿M™ °Pˆî ðEè¬÷ G¬ø«õŸÁA¡ø ªêòŸÃÁè¬÷‚ °P‚A¡øù. îó¾ ñ¬øŠ¹ â¡ð¶ ªð£¼œ«ï£‚° Góô£‚èˆF¡ (Object Oriented Programming-OOP) Ü®Šð¬ìò£ù ð‡¹‚ Ãø£°‹. àÁŠ¹„ ªêòŸÃÁè¬÷ õNº¬øèœ (methods) â¡Á‹. Ý‚Aèœ/ÜNŠHèœ ðŸPŠ ð£ì‹ 8-™ MKõ£èŠ 𮊠«ð£‹. ‘îó¾ ñ¬øŠ¹’ Íôñ£è ‘îó¾ ܼõñ£‚è‹’ ꣈Fòñ£A àœ÷¶ â¡Á‹ Ãøô£‹. private Ü«î Þù‚°¿M¡ àÁŠ¹èÀ‹ „ ªêòŸÃÁèœ (friend functions) âùŠð´‹ Cô CøŠ¹„ ªêòŸÃÁèÀ‹ ñ†´«ñ Üμè º®»‹. å¡Á îó¾ àÁŠ¹èœ (Data Members). îó¾ àÁŠ¹è¬÷Š ð‡¹‚ÃÁèœ (attributes) â¡Á‹ ÃÁõ¶ à‡´.1-ä «ï£‚°è. îó¾ àÁŠ¹èœ â¡ð¬õ æ˜ Þù‚°¿M¡ ð‡¹‚ÃÁè¬÷ à혈¶‹ îó¾ ñ£Pè¬÷‚ °P‚A¡øù.™ õ¬óòÁ‚èŠð†´œ÷ student â¡Â‹ Þù‚°¿¬õ Ü®Šð¬ìò£è‚ ªè£‡´ îèõ™ îóŠð†´œ÷ ܆ìõ¬í6.3 îó¾ ܼõñ£‚è‹ (Data Abstraction) îó¾è¬÷»‹ ªêòŸÃÁè¬÷»‹ å¡Á«ê˜ˆ¶ 埬ø ༠ªð£¼÷£Œ‚ 膮¬õŠð¬î à¬øªð£Fò£‚è‹ (Encapsulation) â¡Á ܬö‚A«ø£‹. ÞŠ«ð£¶. ñŸø¶ àÁŠ¹„ ªêòŸÃÁèœ (member functions). 6. private âù õ¬èŠð´ˆîŠð†ì îó¾è¬÷»‹ ªêò™ÃÁè¬÷»‹ Þù‚°¿¾‚° ªõOJL¼‰¶ Üμè º®ò£¶.

C++ ªñ£NJ™ Þù‚°¿ ñ£Pèœ ªð£¼œèœ (objects) â¡Á ÜPòŠð´A¡øù.marks2. total_marks îó¾ àÁŠ¹èœ accept() compute() display() execute() student() àÁŠ¹„ ªêòŸÃÁèœ Ü™ô¶ õNº¬øèœ stud student Þù‚°¿M¡ ꣡Á¼ (instance)/ ªð£¼œ (object) / ñ£P (variable) ܆ìõ¬í 6. ނßP¡ ªð£¼œ stud â¡ð¶ student Þù‚°¿M¡ ꣡Á¼ (instance) Ü™ô¶ ªð£¼œ (object) â¡ð‹. marks1.1 ™ àœ÷ student Þù‚°¿ 6. ðì‹ 6. Þù‚°¿ õ¬óòÁŠ¹ º®A¡ø ªïO¾ ܬ승‚ °P¬ò 冮. Ü®Šð¬ìˆ îóMùƒèO™ ñ£Pè¬÷ ÜPMŠð¬îŠ «ð£¡«ø Þù‚°¿M™ ªð£¼œèœ ÜPM‚èŠ ð´A¡øù.student îóMù‚ °PŠªðò˜ student â¡ð¬î Þù‚°¿ 冴(tag) â¡Á‹ ÃÁõ˜.1 ªð£¼œè¬÷ à¼õ£‚°î™ 155 .6.1 Program. â¡Â‹ ÜPMŠ¹‚ ߬ø «ï£‚°ƒèœ. name. ñ£PèO¡ ªðò¬ó‚ °PŠH†´‹ ªð£¼œè¬÷ à¼õ£‚è º®»‹. æ˜ Þù‚°¿ õ¬óòÁ‚èŠð†ìH¡. student â¡ð¶ class â¡Â‹ îóMùñ£°‹.5 ªð£¼œè¬÷ à¼õ£‚°î™ student stud. rollno. stud â¡ð¶ student Þùˆ¬î„ ꣘‰î ñ£P. ÜšMùˆF™ ñ£Pè¬÷ ÜPM‚è º®»‹.

marks2. stud. sum â¡Â‹ ñ£P public â¡Â‹ ÜμAò™¹ ªè£‡´œ÷. public âù ÜPM‚èŠð†´œ÷ àÁŠ¹„ ªêòŸÃÁè¬÷ Ü«î Þù‚°¿M¡ ªð£¼œè÷£™ Üμè º®»‹. â´ˆ¶‚裆ì£è. student Þù‚°¿M¡ execute() ªêòŸÃP¬ù ܬö‚°‹ ßÁ Þšõ£Á ܬñ»‹: àÁŠ¹„ ªêòŸÃÁ ¹œO„ ªêòŸ°P ªð£¼O¡ ªðò˜ æ˜ Þù‚°¿M¡ private îó¾è¬÷ Ü«î Þù‚°¿M¡ àÁŠ¹„ ªêòŸÃÁèÀ‹.6 Þù‚°¿ àÁŠ¹è¬÷ Üμ°î™ Þù‚°¿M¡ àÁŠ¹è¬÷Š ¹œO„ ªêòŸ°P Íô‹ Üμè º®»‹. Þó‡´ â‡è¬÷‚ Æ®„ ªê£™½‹ ðE¬ò M÷‚°‹ Program. compute() ÝAò àÁŠ¹„ ªêòŸÃÁèœ ñ†´«ñ Üμè º®»‹.â ¡ ª ø ™ ô £ ‹ Ü μ è º ò ¡ ø £ ™ . stud.6. âù«õ. è£óí‹. „ ªêò™ÃÁèœ âùŠð´‹ Cô CøŠ¹„ ªêòŸ ÃÁèÀ«ñ Üμè º®»‹.6. marks1. total_marks ÝAò îó¾ àÁŠ¹è¬÷. Þù‚ °¿¾‚° ªõO«ò ÜPM‚èŠð†´œ÷ stud â¡Â‹ ªð£¼œ Íôñ£è Üμè º®»‹.execute(). Í¡Á º¿â‡ ñ£Pè¬÷»‹.compute(). stud. private Ü™ô¶ protected âù õ¬óòÁ‚èŠð†´œ÷ àÁŠ¹è¬÷«ò£. stud. execute() â¡ð¶ public âù ÜPM‚èŠð†´œ÷ æ˜ àÁŠ¹„ ªêòŸÃÁ. â¡Â‹ ܬöŠ¹‚ ßÁ ãŸèˆ î‚è«î. ªêòŸÃÁè¬÷«ò£ Üμè º®ò£¶. accept(). ÞF½œ÷ Þù‚°¿.display(). 156 .2 Þ¡«ù£˜ â´ˆ¶‚ 裆죰‹. â´ˆ¶‚裆®™ îóŠð†´œ÷ student Þù‚°¿M™ name. Þù‚°¿¾‚° ªõO«ò ÜPM‚èŠð´‹ ªð£¼œèœ. Ýù£™.accept(). s â¡Â‹ ªð£¼œ Üî¬ù Üμè º®Aø¶.marks1. stud. display(). G ó ™ ª ð ò ˜ Š H “not accessible” â¡Â‹ H¬ö²†´‹ ªêŒF¬òˆ . â‡è¬÷Š ªðŸÁ‚ Æ®ˆ î¼A¡ø ªêòŸÃP¬ù»‹ ªè£‡´œ÷¶.

} õNº¬ø-1 õNº¬ø-2 157 .getdata().7 Þù‚°¿M¡ ªêòŸÃÁè¬÷ õ¬óòÁˆî™ class add { int a.h> class add { private: int a.2 # include <iostream. } 6.b. void main() { add s.//Program . void add::display() { int sum.6. b=10. public: int sum. sum = a+b. } }. cout<<s. sum = a+b. }. void getdata() { a=5.b. public: add() { a = 0.sum. b = 0. cout<<sum. s. } void display().h> # include <conio.

ªêòŸÃP‚° º¡ªù£†ì£è Þ싪ðÁ‹ Þù‚°¿Š ªðò˜ Üî¡ õ¬óªò™¬ô¬ò‚ °P‚°‹. Þù‚°¿¾‚° ªõO«ò õ¬óòÁ‚èŠð´‹ ªêòŸÃÁèœ. â´ˆ¶‚裆´: àÁŠ¹„ ªêòŸÃÁ õ¬óªò™¬ô à혈¶‹ ªêòŸ°P Þù‚°¿Š ªðò˜/ 冴 àÁŠ¹„ ªêòŸÃP¡ îó¾ Þù‹ function_name().õNº¬ø 1-™. õ¬óòÁ‚èŠð†´œ÷¶.  ðô Þù‚°¿‚èœ î‹ ªêòŸÃÁèÀ‚° å«ó ªðò¬óŠ ðò¡ð´ˆF‚ªè£œ÷ º®»‹. add() â¡Â‹ àÁŠ¹„ ªêòŸÃÁ. Þù‚°¿¾‚° ªõO«ò õ¬óòÁ‚èŠ ð†´œ÷¶. Þù‚°¿¾‚°œ õ¬óòÁ‚èŠð´‹ ªêòŸÃÁèœ inline ªêòŸÃÁè¬÷Š«ð£™ Þòƒ°A¡øù. type class_name: : function_name(). Gó™ à¼õ£‚èˆF™ Þ¬õ Ü®‚è® ðò¡ð´ˆF‚ªè£œ÷Š ð´A¡øù. Þù‚°¿M¡ àÁŠ¹„ ªêòŸÃÁè¬÷ Þšõ£Á Þ¼ õ¬èò£è¾‹ õ¬óòÁ‚èô£‹. add Þù‚ °¿¾‚°œ ÜPM‚èŠð†´. add Þù‚°¿ ¾‚°œ«÷«ò ÜPM‚èŠð†´. 158 . àÁŠ¹„ ªêòŸÃÁèœ îQ„CøŠð£ù ð‡Hò™¹è¬÷‚ ªè£‡ ´œ÷ù. â¡Â‹ º¡õ®¬õ‚ ªè£‡´œ÷ù.‚° àKò¶ â¡ð¬î„ ²†´Aø¶. class_name. õNº¬ø 2-™. Ü„ªêòŸÃÁ. ªêòŸÃP¡ î¬ôŠH™ °PŠHìŠð†´œ÷ Þù‚°¿¾‚°œ ÜìƒAò¶ â¡Â‹ õ¬óªò™ ¬ô¬ò‚ °P‚Aø¶. display() â¡Â‹ àÁŠ¹„ ªêòŸÃÁ.‚° º¡ð£è Þ싪ðŸÁœ÷ class_name:: (add::) â¡Â‹ àÁŠ¬ð‚ °P‚°‹ º¡ªù£†´.

è£óí‹. àÁŠ¹„ ªêòŸÃÁèœ Þù‚°¿M¡ private îó¾è¬÷ Üμè º®»‹. 6.  àÁŠ¹„ ªêòŸÃÁ F¼ŠHòŠ¹‹ ñFŠ¹. quantity. void display(). void main() { product p1. Þù‚°¿M¡ ªð£¼÷£è¾‹ Þ¼‚èô£‹. ܉î Þù‚°¿¬õ„ ꣘‰î ܬùˆ¶Š ªð£¼œ èÀ«ñ å«ó àÁŠ¹„ ªêòŸÃP¬ù«ò ðò¡ð´ˆF‚ ªè£œõ.8 ªð£¼œèÀ‚° G¬ùõè 嶂W´ Þù‚°¿ õ¬óòÁŠH¡ å¼ ð°Fò£è àÁŠ¹„ ªêòŸÃÁèœ õ¬ó òÁ‚èŠð†®¼‚°‹«ð£«î ܬõ à¼õ£‚èŠð†´ G¬ùõèˆF™ Þ¼ˆîŠð´A¡øù. p2. }.  àÁŠ¹„ ªêòŸÃÁèœ static Þùñ£è¾‹ Þ¼‚è º®»‹. ¹œO„ ªêòŸ°P «î¬õJ™¬ô. ªð£¼œè¬÷»‹ ªêò½¼¹è÷£è ÜŠH¬õ‚è º®»‹. àÁŠ¹ ñ£PèÀ‚°ˆ «î¬õò£ù G¬ùõè Þì‹ ñ†´‹ 嚪õ£¼ ªð£¼À‚°‹ îQˆîQ«ò 嶂èŠð´Aø¶. ãŸèˆî° C++ îó¾ Þù„ ªêò½¼¹è¬÷ 㟰‹. (Þšõ£Á ܬñõ¶ àÁŠ¹„ ªêòŸÃÁèO¡ H¡ùô¬ñŠ¹ âùŠð´Aø¶). ªõš«õÁ ªð£¼œèÀ‚° ªõš«õÁ Þì‹ å¶‚èŠ ð´õ¶ è†ì£òñ£°‹. 嚪õ£¼ ªð£¼œ à¼õ£‚èŠð´‹«ð£¶‹ àÁŠ¹„ ªêòŸÃÁèÀ‚°ˆ îQˆîQ G¬ùõè Þì‹ å¶‚èŠð´õF™¬ô. ªõš«õÁ ªð£¼œèO¡ àÁŠ¹ ñ£Pèœ ªõš«õÁ ñFŠ¹è¬÷‚ ªè£‡®¼‚°‹. àÁŠH™ô£î ªêòŸÃÁèœ Üμè º®ò£¶. float price. W«ö»œ÷ Þù‚°¿ ÜPMŠ¬ð «ï£‚°è: class product { int code.  æ˜ àÁŠ¹„ ªêòŸÃÁ Þ¡«ù£˜ àÁŠ¹„ ªêòŸÃP¬ù «ïó®ò£è ܬö‚è º®»‹. public: void assign_data(). } 159 .  àÁŠ¹„ ªêòŸÃÁèœ.

àÁŠ¹ ñ£P‚° å«óªò£¼ ïè™ ñ†´«ñ Þ¼‚°‹ (ªð£¶ ÞìˆF¡ å¼ ð°Fò£è). price 8 ¬ð†´èœ ܆ìõ¬í 6.  G¬ùõèˆF™. Üî¡Hø° ªî£ì‚è ñFŠH¼ˆîŠð´õF™¬ô.™ M÷‚èŠ ð†´œ÷¶«ð£ô. Ü«î Þù‚°¿M¡ Hø ªð£¼œèÀ‹ G¬ùõèˆF½œ÷ ܉îªõ£¼ ïè¬ô«ò ðA˜‰¶ªè£œA¡øù. price 8 ¬ð†´èœ p2 code.3. p1. quantity. display() ÝAò¬õ G¬ùõèˆF™ ªð£¶MìŠ ð°FJ™ Þ¼ˆîŠð´A¡øù. Ýù£™ Üî¡ õ£›ï£œ.2 ªð£¼œèÀ‚è£ù G¬ùõè 嶂W´ æ˜ Þù‚°¿M¡ àÁŠ¹„ ªêòŸÃÁèœ. 0 â¡ø ªî£ì‚è ñFŠ¬ðŠ ªðÁ‹. 6. static àÁŠ¹ ñ£P ðò¡ð´ˆîŠð†´œ÷ å¼ Gó¬ô‚ 裇è (Program-6.ÞF½œ÷ àÁŠ¹„ ªêòŸÃÁèœ assign_data(). àÁŠH™ô£î «õªø‰î„ ªêòŸÃÁè¬÷»‹ «ð£ô«õ ªêò½¼¹è¬÷‚ ¬èò£÷ º®»‹.  Üî¡ õ¬óªò™¬ô»‹ ÜμAò™¹‹ ܉î Þù‚ °¿¾‚°œ«÷. Program. static îó¾ àÁŠ¹ ܉î Þù‚°¿M™ ºî™ ªð£¼œ à¼õ£‚èŠð´‹«ð£¶.9 static îó¾ àÁŠ¹èœ Þù‚°¿M¡ å¼ îó¾ àÁŠ¹‚° static â¡Â‹ î°F¬ò ÜO‚è º®»‹.4): 160 . quantity. p2 ÝAò Þó‡´ ªð£¼œèÀ‹ ªð£¶MìŠ ð°FJ½œ÷ è†ì¬÷è¬÷ Üμè º®»‹. p2 ÝAò Þó‡´ ªð£¼œèO¡ G¬ùõè 嶂W†¬ì‚ 裇è: ªð£¼œ îó¾ àÁŠ¹èœ G¬ùõè 嶂W´ p1 code.6. Üî£õ¶ p1. Gó™ ªêò™ð†´ º®»‹õ¬ó Þ¼‚°‹.

} }.h> #include<conio.assign_data( 101. int q.display(). } void display() { cout<<“\n Code : “<<code. cout<<“\n Quantity :”<<quantity.5). p. cout<<“\n Price : “<< price. quantity = q. void main() { product p. public: void assign_data( int c. float p) { code = c. price = p. float price. } 161 . 200.h> class product { int code. p. 12.// Program .3 #include<iostream. quantity.6.

display(). static_simple. } void display() { cout<<“\n The sum of two numbers … “<<sum. “.display(). p2. void main() { simple_static p1. p1. cin>>a>>b. p3.sum. } }.accept().accept().p2. count++.p3.h> #include<conio.6.// Program .h> class simple_static { int a.b. cout<<“\n This is addition… “<<count. p2.accept(). static int count. public: void accept() { cout<<“\n Enter values.count = 0.4 // To demonstrate the use of static member variables #include<iostream. } 162 . p3. sum = a+b.display().. p1.

ðì‹ 6.¡ ñFŠ¹ 3 ÝAø¶. Þ¶. 163 . ܬùˆ¶Š ªð£¼œèÀ‹ count.. count.count static àÁŠ¹ ñ£PJ¡ ªî£ì‚è ñFŠ¹ Þù‚°¿¾‚° ªõO«ò Þ¼ˆîŠð´Aø¶. accept() ªêòŸÃÁ º‹º¬ø ªêò™ð´ˆîŠð´õ count-¡ ñFŠ¹‹ º‹º¬ø I°‚èŠð†´ 3 â¡Â‹ ñFŠ¬ðŠ ªðÁAø¶.2-™ M÷‚èŠð†´œ÷¶. 9 8 The sum of two numbers ……………17 This is addition 3 static ñ£Pò£ù count å«óªò£¼ º¬ø ñ†´‹ 0 âùˆ ªî£ì‚è ñFŠH¼ˆîŠð´Aø¶.ªõOf´: Enter values …… 10 20 The sum of two numbers ………… 30 This is addition 1 Enter values……… 5 7 The sum of two numbers……………12 This is addition 2 Enter values……….¡ å«óªò£¼ ïè¬ô ñ†´«ñ ðA˜‰¶ªè£œõ.2 static àÁŠ¹ ñ£P . ðì‹ 6. 嚪õ£¼ º¬ø Þó‡´ â‡èO¡ Æ´ˆªî£¬è èí‚AìŠð´‹«ð£ªî™ô£‹ count-¡ ñFŠ¹ å¡Á I°‚èŠð´Aø¶.

display(). void init() { a =b = 0. void display(). int sum() { return a+b. float price.assign_Data().6. H¬öè¬÷‚ è‡ìP‰¶ F¼ˆ¶è: class x { public: int a. int square(). } p[3]. } 164 .b.10 ªð£¼œèO¡ ÜEèœ W›‚è£μ‹ Þù‚°¿ õ¬óòÁŠ¬ð»‹. void main() { p[0]. p[0]. Üî¡ G¬ùõè 嶂W†¬ì»‹ «ï£‚°è: class product { int code. } int sum(). public : void assign_Data().quantity. }. } code quantity price p[0] code quantity price p[1] code quantity price p[2] ðJŸC Mù£‚èœ I.

int square()
{
return sum() * sum()
}

M“:

int x : : sum() ñŸÁ‹ int x : : square()
II.
#include<iostream.h>
class simple
{
int num1, num2 , sum = 0;
protected:
accept()
{
cin>>num1>>num2;
}
public:
display()
{
sum = num1 + num2;
}
};
void main()
{

simple s;
s.num1=s.num2=0;
s.accept();
display();

}

165

M“:
1) sum â¡Â‹ àÁŠ¹ ñ£PJ™ ÜPMŠH¡«ð£¶ ªî£ì‚èñFŠ¹
Þ¼ˆî º®ò£¶.
2) num1, num2 ÝAò àÁŠ¹ ñ£Pèœ private â¡ð ÜõŸ¬ø
main()- L¼‰¶ Üμè º®ò£¶.
3) s.accept() â¡Á ܬö‚è º®ò£¶. è£óí‹ Ü¶ protected âù
õ¬óòÁ‚èŠð†´œ÷¶.
4) display() â¡Â‹ ªêòŸÃP¬ù å¼ ªð£¼O¡ Íô‹ ܬö‚è
«õ‡´‹.
III.
#include<iostream.h>
#include<conio.h>
class item
{
private:
int code,quantity;
float price;
void getdata()
{
cout<<“\n Enter code, quantity, price “;
cin>>code>>quantity>>price;
}
public:
float tax = 0;
void putdata()
{
cout<<“\n Code : “<<code;
cout<<“\n Quantity : “<<quantity;
cout<<“\n Price : “<<price;
if( quantity >100 )
tax = 2500;
else
tax =1000;

166

cout<<“ \n Tax :”<<tax;
}
};
void main()
{ item i; }

«ñŸè‡ì GóL¡ Ü®Šð¬ìJ™ W›‚è£μ‹ ܆ìõ¬í¬ò G¬ø¾
ªêŒè:
꣡Á¼ i- ¡
G¬ùõè
嶂W´
IV.
1)

private îó¾

àÁŠ¹èœ

public îó¾

àÁŠ¹èœ

i Íô‹ Üμè

º®Aø ªêòŸÃÁ
èÀ‹ îó¾
àÁŠ¹èÀ‹

W›‚è£μ‹ õ¬óòÁŠ¹èÀì¡ employee â¡Â‹ æ˜ Þù‚°¿¬õ
õ¬óòÁ‚辋:
employee Þù‚°¿M¡ private àÁŠ¹èœ:
empno - º¿â‡
ename - 20 ⿈¶èœ
basic - float
netpay, hra, da - float
calculate()- basic+hra+da â¡ð¬î‚ èí‚A†´ å¼ float

ÞùñFŠ¬ðˆ F¼ŠHòŠ¹‹ ªêòŸÃÁ.
employee Þù‚°¿M¡ public àÁŠ¹„ ªêòŸÃÁèœ:
havedata() - empno, ename, basic, hra, da - ÝAò ñFŠ¹è¬÷
àœkì£èŠ ªðŸÁ, calculate() ªêòŸÃP¬ù ܬöˆ¶
netpay- ä‚ èí‚Aì„ ªêŒ»‹ ªêòŸÃÁ.
dispdata() - îó¾ àÁŠ¹èœ ܬùˆ¬î»‹ F¬óJ™ 裆´‹
ªêòŸÃÁ.
2)

W›‚è£μ‹ õ¬óòÁŠ¹èÀì¡ math â¡Â‹ Þù‚°¿¬õ
õ¬óòÁ‚辋:
private àÁŠ¹èœ:
num1, num2, result - float
init() ªêòŸÃÁ - num1, num2, result ÝAòõŸP™ 0 â¡Â‹ ªî£ì‚è

ñFŠH¼ˆ¶‹.

167

protected àÁŠ¹èœ:
add() ªêòŸÃÁ - num1, num2 Þó‡¬ì»‹ Æ®, Æ´ˆ
ªî£¬è¬ò result- ™ Þ¼ˆ¶‹.
prod() ªêòŸÃÁ - num1, num2 Þó‡¬ì»‹ ªð¼‚A, ªð¼‚°ˆ
ªî£¬è¬ò result- ™ Þ¼ˆ¶‹.
public àÁŠ¹èœ :
getdata() ªêòŸÃÁ - num1, num2 ÝAò ñFŠ¹è¬÷ 㟰‹
menu() ªêòŸÃÁ 1. Add...
2. Prod...
â¡Â‹ ð†®¬ò‚ (menu) 裆´‹.

1 â¡ð¬îˆ «î˜¾ ªêŒî£™ add() ªêòŸÃP¬ù»‹, 2-äˆ «î˜¾
ªêŒî£™ prod() ªêòŸÃP¬ù»‹ ªêò™ð´ˆF, result- äˆ F¬óJ™
裆ì«õ‡´‹.

168

13 11:59:19 +05'30' ð£ì‹ 7 𙽼õ£‚è‹ (Polymorphism) 7.. å«ó ªðòK™ (ªõš«õÁ Ü÷¹¼‚èÀì¡) õ¬óòÁ‚è º®»‹. float area(float half.Ramanathan Digitally signed by Ramanathan DN: cn=Ramanathan. C++ ªñ£NJ™.Ph:9442282076 Date: 2008. å¼ Góô˜ W›‚è£μ‹ ªêòŸÃÁè¬÷ õ¬óòÁ‚è M¼‹¹Aø£˜ âù ¬õˆ¶‚ªè£œ«õ£‹: area_circle() area_triangle() area_rectangle() // å¼ õ†ìˆF¡ ðóŠ¬ð‚ èE‚è // å¼ º‚«è£íˆF¡ ðóŠ¬ð‚ èE‚è // å¼ ªêšõèˆF¡ ðóŠ¬ð‚ èE‚è ªõš«õÁ õ®õƒèO¡ ðóŠð÷¬õ‚ è‡ìPò â¿îŠð†ì «ñŸè‡ì Í¡Á º¡õ®¾è¬÷»‹.1 º¡Â¬ó polymorphism â¡ø ªê£™. float area(float length.03. 𙽼õ£‚è‹.2 ªêòŸÃÁ ðEI°Š¹ (Function Overloading) ªêŒF Ü™ô¶ îóM¬ù å¡Á‚° «ñŸð†ì õ®õƒèO™ ªêòô£‚èõ™ô ªêòŸÃP¡ Fø¬ù«ò ªêòŸÃÁ ðE I°Š¹ â¡A«ø£‹. à‡¬ñJ™ ‘ðEI°Š¹’ (overloading) â¡ð¶ å«ó ªðò˜.com Location: Commercial Taxes Staff Training Institute. float area(float radius). ªêòŸ°P ðEI°Š¹ (operator overloading) ÝAòõŸP¡ Íô‹ G¬ø «õŸøŠð´Aø¶. morph-shapes) â¡Â‹ ªð£¼¬÷ˆ î¼Aø¶. email=ctdsti@gmail. c=IN. ‘ðô õ®õƒèœ’ (poly-many. float height). 7. ou=Computer Lecturer. ‘ðEI°ˆî ªêòŸÃÁ’ â¡ð¶ å¡Á‚° «ñŸð†ì îQˆî ªð£¼œ ªè£‡ì ªêòŸÃP¬ù‚ °P‚Aø¶. Computer Lecturer. ªð£¼œ«ï£‚° Góô£‚舶‚°ˆ ¶¬í¹K»‹ ‘ªêòŸÃÁ ðEI°Š¹’ C++ ªñ£NJ¡ ð‡¹‚ÃÁèO™ å¡ø£°‹. float breadth).. float base. ªêòŸÃÁ ðEI°Š¹ (function overloading). 169 . å¡Á‚° «ñŸð†ì ªõš«õÁ ªð£¼¬÷ à혈¶õ¬î‚ °P‚Aø¶. o=Commercial Taxed Dept Staff Training Institute. îIN™ 𙽼õ£‚è‹ â¡A«ø£‹. Ýè.

.. break. Circle .“ << area(h.b). } float area (float half. return (half* base*height). case 2: cout<< “\n Enter base. cout << “\n 1. return ( length *breadth ). “.”. cin>>r.. Exit . cin>>h>>b... } 170 ...ÞŠ«ð£¶ Program-7.. breadth... break. } void main() { clrscr(). cin>>b>>h. “. Traingle .. cout << “\n 2. Rectangle .. getch().. cout<<“\n The area of a rectangle is . “ << area(r).b. “. cout<<“\n The area of circle is . float breadth ) { cout << “\nRectangle …”. cin>> choice.h> #include<conio. cout <<“\n 4....5. h). break. case 3: cout<< “\n Enter length. switch(choice) { case 1 : cout << “\n Enter radius .1 // to demonstrate the polymorphism . } float area ( float length. “. Í¡Á õ®õƒèO™ â‰î õ®õˆF¡ ðóŠð÷¬õ»‹ èí‚Aì area() â¡Â‹ ªêòŸÃP¬ù„ ªêò™ ð´ˆF»œ÷¬ñ 裇è: // Program .1-ä «ï£‚°è. cout << “\n 3. b.7. float height) { cout << “\nTriangle .. getch().. do { clrscr(). int choice = 0. cout<<“\n The area of a triangle is. float base. “.”.h. return ( 22/7 * radius * radius ). height . getch().function overloading #include<iostream.. float r.h> float area ( float radius ) { cout << “\nCircle …”. } }while (choice <=3). cout << “\n Area Menu “. “.“ << area (0..

Í¡ø£õF™ Þó‡´ ªêò½¼¹èÀ‹ àœ÷ù. ªêò½¼¹èO¡ â‡E‚¬è å¡ø£è Þ¼ŠH¡ ÜõŸP¡ îóMùƒèœ ñ£P Þ¼‚è «õ‡´‹. Iè„Cø‰î ªð£¼ˆî‹ (Best Match) â¡Â‹ ªêò™¸†ðˆ¬îŠ H¡ðŸÁAø¶. void fun(char ch). void fun(int y). âù«õ H¬öò£°‹. ªêòŸÃÁ ðEI°ŠH™ ªêòŸÃÁèœ âšõ£Á Þò‚èŠð´A¡øù? Gó™ªðò˜ŠH. Þ‰î„ ªêò™¸†ðˆF¡ð® Gó™ ªðò˜ŠH ªêòŸÃÁ ܬöŠ¹‚ ßÁ‚° Iè„ êKò£èŠ ªð£¼‰¶‹ ªêòŸÃÁ º¡õ®¬õˆ «î® 𣘂°‹. ¬ìò â´ˆ¶‚ 裆®™ Í¡Á ªêòŸÃÁèÀ«ñ float Þù„ ªêò½¼¹è¬÷‚ ªè£‡ ´œ÷ù. Þó‡´‹ å«ó â‡E‚¬è J™ å«ó Þù„ ªêò½¼¹ è¬÷‚ ªè£‡´œ÷ù. void fun(int x). W›‚è£μ‹ º¡õ®¾èO™ ªêòŸÃÁ ðEI°Š¹‚è£ù º¡õ®¾ èO™ H¬öò£ù¬î‚ è‡ìPò º®»ñ£? ã¡ â¡Á è£óí‹ Ãø º®»ñ£? ªêòŸÃÁ º¡õ®¾èœ: H¬öò£ù º¡õ®¾èœ: void fun(int x). void fun(double d). Þó‡ì£õF™ Í¡Á ªêò½¼¹èÀ‹. 171 . float area(float half. 嚪õ£¼ º¡ õ®¾‹ ªõš«õÁ îóMù„ ªêò½¼¹è¬÷‚ ªè£‡®¼‚èô£‹. ªêò½¼¹èO¡ â‡E‚¬è ªõš«õø£è Þ¼‚èô£‹. ºîô£õ¶ º¡õ®M™ å¼ ªêò½¼¹‹. flaot height). float breadth).Í¡Á ªêòŸÃÁèO¡ º¡õ®¾è¬÷‚ èõQˆb˜è÷£? ܬõ: float area(float radius). void fun(int y). Í¡Á area() ªêòŸÃÁèO¡ õ¬óò¬øèÀ‹ å¡Á‚ªè£¡Á ñ£Á ð†´œ÷ù â¡Á G¬ù‚Al˜è÷£? Ý‹. 嚪õ£¼ ªêòŸÃP¡ º¡ õ®¾‹ ªêò½¼¹èO¡ â‡E‚¬èJ™ «õÁð´A¡øù. Þšõ£Á Þ¼‚è «õ‡´‹ â¡ðF™¬ô. float base. float area(float length.

â‡õ¬è„ ªêò½¼¬ð «õÁ â‡õ¬è‚° Þùñ£Ÿø‹ ªêŒ¶. º¿â‡ õ¬è Þùñ£ŸøˆF¡ð®.1) float area (float radius) â¡Â‹ º¡õ®¾ àœ÷¶. ªõš«õÁ Gó™ªðò˜ŠHèœ ªõš«õÁ õ¬èJ™ Þùñ£Ÿø‹ ªêŒòô£‹. Iè„ êKò£èŠ ªð£¼‰¶‹ ªêòŸÃÁ Þ™¬ôªòQ™.1 GóL™ àœ÷ area() ªêò™ÃP‚° ܬöŠ¹‚ ßÁ W›‚è£μñ£Á ܬñ»ªñQ™ M¬ì â¡ùõ£è Þ¼‚°‹? ªêòŸÃÁ ܬöŠ¹‚ ßÁ area (5.  int îóMùˆ¬î char/float/double Þùñ£è ñ£Ÿø º®»‹. int ñ£PL/ñ£P¬ò char Ü™ô¶ float Ü™ô¶ double Þùˆ«î£´ ªð£¼ˆF‚ªè£œ÷ º®»‹. Ü´ˆ¶Š ªð£¼ˆîºœ÷ ªêòŸÃP¬ùˆ «î´‹. â´ˆ¶‚裆ì£è.  float îóMùˆ¬î int/double/char Þùñ£è ñ£Ÿø º®»‹. ÜèŸø ªêòŸÃÁ º¡õ®¾ àœ÷î£ âùŠ 𣘂°‹.0.5. â‡õ¬è Þùñ£Ÿø‹ ªð¼‹ð£½‹ Þšõ£Á ܬñ»‹:  char îóMùˆ¬î int/float/double Þùñ£è ñ£Ÿø º®»‹. r â¡ð¶ int Þùñ£è Þ¼‚°‹ âQ™. Þˆî¬èò â‡õ¬è Þùñ£Ÿø‹ º¿‚è º¿‚è Gó™ªðò˜ŠH ꣘ð£ù¶.0.5) 172 ªõOf´ . Program-7. 4.  double îóMùˆ¬î int Ü™ô¶ float Þùñ£è ñ£Ÿø º®»‹. 6. Üî£õ¶. Þ„ªêò™¸†ðˆF¡ ð® area(r) â¡Â‹ ܬöŠ¹ area(float radius) â¡Â‹ ªêòŸÃ«ø£´ ªð£¼ˆîŠð†´ ܶ Þò‚èŠð´‹. «ñŸè‡ì GóL™ (Program-7. Þ𣼜.0) area(3. ܬöŠ¹‚ ßÁ area(r) â¡ðF™ r â¡Â‹ ªêò½¼¹ float Þùˆ¬î„ «ê˜‰î£è Þ¼‚è «õ‡´‹.0) area (0. 4.

ðEI°ˆî ªêòŸÃÁèœ F¼ŠHòŠ¹‹ îóMù‹ å¡ø£è Þ¼‚èô£‹. int times) { for (int i=1. W«ö»œ÷õ£Á ªêòŸÃÁ ܬöŠHQ™ «ñ£î¬ô à¼õ£‚°‹. i<=times.i++) cout<<a. i<=times . ðEI°ˆî ªêòŸÃÁèO¡ º¡Qò™¹„ ªêò½¼¹è¬÷. void fun ( char a. ªî£ì˜H™ô£î Þ¼ ªêòŸÃÁèÀ‚° å«ó ªðò¬ó„ ņì£ñ™ Þ¼Šð¶ ï™ô¶. } 173 . } void fun( int times) { for(int i=1. º¬øòŸø ÜPMŠ¹èœ. fun(60). 60). int times ) { for(int i=1.i<=times.i++) cout<<’@’.i++) cout<<a.ªêòŸÃÁ ðEI°ŠH¡ MFº¬øèœ 1) 2) 3) 4) ðEI°ˆî ªêòŸÃÁ蜺¬øò£ù Ü÷¹¼‚èO¡ â‡E‚¬è J«ô£. } void main() { fun ( ‘+’. ÜõŸP¡ îó¾ ÞùƒèO«ô£ «õÁð†®¼‚è «õ‡´‹. } void fun( char a= ‘*’. Ü÷¹¼‚èO¡ ð†®òL™ å¼ ð°Fò£è C++ Gó™ªðò˜ŠH è¼F‚ ªè£œ÷£¶. «õÁð†´‹ Þ¼‚èô£‹.

int times) and fun (int times) fun (‘+’. ðòù˜ è†ì£òñ£è strcat() ªêòŸÃP¬ù«ò ðò¡ð´ˆî «õ‡´‹. C++ ªñ£NJ™ Þšõ£Á + ªêòŸ°P Íô‹ Þó‡´ êóƒè¬÷ å¡P¬í‚è º®»ñ£? Þó‡´ êóƒè¬÷ Þ¬í‚è + ªêòŸ°P¬òŠ ðò¡ð´ˆî Þòô£¶ âù Gó™ªðò˜ŠH H¬ö ²†´‹.3 ªêòŸ°PŠ ðEI°Š¹ (Operator Overloading) ‘ªêòŸ°PŠ ðEI°Š¹’ â¡ð¶. last_name ÝAò¬õ Í¡Á‹ êóƒèœ (char Þù ÜEèœ) Ý°‹. -=. ÞF™ name. first_name. <. > «ð£¡ø C++ ªêòŸ°PèÀ‚°‚ ôîô£ù ªêò™ð£†®¬ù õ¬óòÁŠð¬î‚ °P‚Aø¶. «õÁð£ì£ù Ü÷¹¼Š ð†®ò™èœ ªè£‡ì ªêòŸÃÁèO¡ Íôñ£è«õ å¼ ªêòŸÃP‚°Š ðEI°‚è «õ‡´‹. +. sum = num1 + num 2. M¬ì¬ò sum â¡Â‹ ñ£PJ™ Þ¼ˆ¶‹ ðE‚è£ù ßø£è‚ è¼F‚ ªè£œ÷Šð´‹. ++. 174 . Üî£õ¶. *. int times) and fun(char a = ‘*’. ÞŠ«ð£¶. --. 7. int times) ÝAò Þó‡´ ªêòŸÃÁèÀì‹ ªð£¼ˆîº®»‹. Þó‡´ êóƒè¬÷ Þ¬í‚è.«ñŸè‡ì Gó¬ô Gó™ªðò˜‚°‹«ð£¶ Þó‡´ H¬öèœ ²†ìŠð´‹:  conflict between fun(char a. W›‚è£μ‹ ߬ø «ï£‚°è: name = first_name + last_name. Þó‡´ â‡è¬÷‚ (int/float/double) Æ®. Ü÷¹¼Š ð†®ò™. -. ⇠Þùˆ¶‚°Š ðò¡ð´ˆ¶õ¶ «ð£ô«õ êóƒ èÀ‚°‹ + ªêòŸ°P¬òŠ ðò¡ð´ˆî º®‰î£™ I辋 âOî£è Þ¼‚°‹ Ü™ôõ£? ªêòŸ°PŠ ðEI°Š¹ ¸†ð‹ Íô‹ + ªêòŸ°PJ¡ ªêò™ð£†¬ì„ êóƒèÀ‚°‹ c†®‚è º®»‹. int times)  conflict between fun(char a = ‘*’. â¡Â‹ ßÁ. +=. 60) â¡Â‹ ܬöŠ¹‚ ߬ø fun(char a. int times) ñŸÁ‹ fun(char a = ‘*’. Ü÷¹¼‚èO¡ â‡E‚¬è Ü™ô¶ îóMùƒèœ Ü®Šð¬ìJ™ «õÁð†®¼‚è «õ‡´‹.

strcpy(temp. char *concatstr .h> # include <string. } void main() { clrscr().s2(“ run\0”). getch(). s1.x1. return temp.s). } strings(char *c) { strcpy(s. char * operator + (strings x1) â¡Â‹ àÁŠ¹„ ªêòŸÃÁ Íôñ£è. return temp. s2 ÝAò Þ¼ ªð£¼œ èÀ‹ strings Þù‚°¿¬õ„ ꣘‰î¬õ.s). ÞšM¼ ªð£¼œ è¬÷»‹ Þ¬í‚è + ªêòŸ °P ðò¡ð´ˆîŠð†´œ÷¶. â¡Â‹ ßÁ Þó‡´ êóƒè¬÷ å¡P¬í‚°‹. public : strings() { s[0] = ‘\0’. strcat(temp. strings s1(“test”).h> # include <conio. strcpy(temp. 175 .” << concatstr.s). + ªêòŸ°P‚° ôîô£ù ðE õ¬óòÁ‚èŠð†´œ÷¶. Þî¬ù Þšõ£Á M÷‚èô£‹: x1 â¡Â‹ ªêò½¼¹ ðòù˜ õ¬óòÁˆî strings â¡Â‹ char * operator+(strings x1) { char *temp. cout <<“\nConcatenated string .h> class strings { char s[10]. Þ„ªêòŸÃÁ ðòù˜ õ¬óòÁˆî x1 â¡Â‹ îóMùŠ ªð£¼¬÷„ ªêò½¼ð£è ãŸAø¶.s). } char * operator+(strings x1) { char *temp. concatstr = s1 + s2. } }. } îóMùˆ¬î„ ꣘‰î¶.W«ö»œ÷ â´ˆ¶‚裆¬ì‚ 裇è: // Program -7.. concatstr = s1 + s2. strcat(temp.2 – OPERATOR OVERLOADING # include <iostream. concatstr = s1 + s2.c).x1..

++. Ü™ô¶ „ ªêòŸÃÁè÷£è (friend functions) Þ¼‚è «õ‡´‹.1. --.  å¼ ªêòŸ°P‚°ˆ îóŠð´‹ ¹Fò õ¬óò¬ø Ü„ªêòŸ °PJ¡ Íô õ¬óòÁŠ¬ð ñ£Ÿø º®ò£¶. Üî£õ¶. ðì‹ 7. <. *. â´ˆ¶‚裆ì£è. („ ªêòŸÃÁèœ Þ‰î ËL¡ õ¬óªò™¬ô‚° ÜŠð£Ÿð†ì‹).  ªêòŸ°PèÀ‚è£ù ªêòŸÃÁèœ àÁŠ¹„ ªêòŸÃÁè÷£è Þ¼‚è «õ‡´‹.1 ñ£PèÀ‚°‹ ñFŠ¹èÀ‚°‹ àœ÷ ªî£ì˜¹ ‘ªêòŸ°PŠ ðEI°Š¹’ ÞõŸ¬øªò™ô£‹ õöƒ°Aø¶:  +. Gó™ªðò˜ŠH. Ü«î GóL™ + ªêòŸ°P¬ò õö‚è‹«ð£ô Þó‡´ â‡è¬÷‚ Æ´‹ ðE‚°‹ ðò¡ð´ˆî º®»‹. Ü®Šð¬ìò£ù ªêòŸ°PèÀ‚°Š ¹Fò õ¬óò¬øè¬÷ õöƒ°Aø¶. -. += ñŸÁ‹ Þ¶«ð£¡ø C++ ªñ£NJ¡  ðòù˜ õ¬óòÁ‚°‹ îóMùƒèÀ‚°‹ ðEI°ˆî ªêòŸ°Pè¬÷ õ¬óòÁ‚è º®»‹. «ñŸè‡ì GóL™ + ªêòŸ°P Þó‡´ êóƒè¬÷ å¡P¬í‚èŠ ðò¡ð´ˆîŠð†´œ÷¶. ñ£PèÀ‚°‹ ÜõŸP¡ ñFŠ¹èÀ‚°‹ Þ¬ì«òò£ù ªî£ì˜H¬ù M÷‚°Aø¶. â¡Â‹ è†ì¬÷ 15 âùˆ F¬óJ™ 裆´‹. 176 . ðòù˜ õ¬ó òÁˆî ªêòŸ°PJ¡ è†ì¬÷è¬÷ æ˜ Ü¬öŠ¹‚߬øŠ «ð£ô«õ ªêò™ð´ˆ¶Aø¶.ðì‹ 7. >. (+-¡ Íô õ¬óò¬ø ªêò™ð´ˆîŠð†´œ÷¶). cout << 5+10.

 operator <symbol>() ªêòŸ°P¬ò Þù‚°¿M¡ public ð°FJ™ ÜPM‚è «õ‡´‹. negative n1.7. public : void accept() { cout << “\nEnter a number . } }. } . æ˜ Þù‚ °¿M™ àœ÷ îó¾ àÁŠ¹èO¡ âF˜ñ ñFŠ¹è¬÷‚ (negative value) è‡ìPò . n2. } 177 void operator-() { i = -i. // Program .. -n2.h> # include <conio.display().”<<i..7..3 M÷‚°Aø¶.3 # include <iostream.ªêòŸ°P¬òŠ ðò¡ð´ˆ¶‹ º¬ø¬ò Program . â¡Â‹ è†ì¬÷..h> class negative { int i. } void display() { cout << “\nNumber .accept(). char * operator+(strings x1) â¡Â‹ àÁŠ¹„ ªêòŸÃP¬ù„ ªêò™ð´ˆ¶‹.  «î¬õò£ù ªêò™ð£´è¬÷ G¬ø«õŸP‚ªè£œÀ‹ õ¬èJ™ ªêòŸ°P‚è£ù ªêòŸÃP¬ù õ¬óòÁ‚è «õ‡´‹. ÞF™ + ªêòŸ°PJ¡ Þ¼¹øº‹ Þ싪ðŸÁœ÷ ªêò«ôŸHèœ s1. è£óí‹. getch(). n2. s2 ÝAò Þó‡´‹ strings Þù‚°¿M¡ ªð£¼œ è÷£°‹.n2. void main() { clrscr(). ðòù˜ õ¬óòÁˆî îóMùŠ ªð£¼œèœ ªêòŸ°PèO™ âO¬ñò£è‚ ¬èò£÷Šð†®¼Šð¬î‚ W«ö»œ÷ â´ˆ¶‚裆´ M÷‚°Aø¶. cin >> i.concatstr = s1 + s2.”. ªêòŸ°PŠ ðEI°ŠH™ ï¬ìªðÁ‹ ªêò™ð£´èœ:  å¼ ¹Fò îóMùˆ¬î õ¬óòÁ‚°‹ Þù‚°¿¬õ à¼õ£‚A ܈îóMùŠ ªð£¼œè¬÷Š ðEI°ˆî ªêòŸ°PJ™ ðò¡ð´ˆF‚ªè£œ÷ «õ‡´‹.

distance dist_1. inches = i. dist_3.distance_assign(24. } }. Þù‚ °¿M¡ îó¾ àÁŠ¹è¬÷ void operator-() â¡Â‹ ªêòŸÃÁ âF˜ñ‹ (Negative) Ý‚°Aø¶. â¡ðF™. } distance operator+(distance d2) { distance d3. d3. return d3.dist_2.feet. getch().display().ªêòŸ°P ªêò™ð´õ¶ «ð£ô.sum = .display(). d3.feet += (inches + d2. void main() { clrscr(). } void display() { cout << “\nFeet : “ << feet << “\tInches : “ << inches. dist_1.h> class distance { int feet. W«ö»œ÷ Gó¬ô «ï£‚°è. dist_1.11) dist_2.display().inches) % 12. public : void distance_assign(int f.num1.4 # include <iostream. Mù£‚èÀ‚° M¬ì î¼è: // Program – 7.distance_assign(12. distance dist_3 = dist_1 + dist_2. } 178 . ê£î£óí ñ£PèÀ‚° . int i) { feet = f.h> # include <conio. dist_2. d3.inches = (inches + d2.feet = feet + d2.inches.1).inches)/12.

.. } void display() { cout << cout << cout << cout << } “\n “\n “\n “\n Book details . ðEI°‚èŠð†ì +=..” << name.. ðEI°‚èŠð†ì àÁŠ¹„ ªêòŸÃP¡ º¡õ®¬õ â¿F‚ 裆´è.1. 3. Name . ÝAò ªêòŸÃÁè¬÷ Program-7. ðEI°‚èŠð†ì ªêòŸ°PJ™ ðò¡ð´ˆîŠð†´œ÷ ªêò«ôŸHèO¡ Þù‹ ò£¶? 4. 1. int code.h> class library_book { char name[25].”. } void operator -=(int x) { stock -= x.. Code . } }. -= M÷‚°Aø¶.” << stock.. void operator +=(int x) { stock += x.int s) { strcpy(name. ðEI°‚èŠð†ì ªêòŸ°Pè¬÷ ܬìò£÷‹ 裇è.” << code. 3. public : void book_assign(char n[15]. code = c.. 2.n)...int c. Stock ..5 //Program-7..h> # include <conio. 2.5 // operator overloading # include <iostream.. ðEI°‚èŠð†ì àÁŠ¹„ ªêòŸÃP¬ù Þò‚°‹ ßP¬ù â¿F‚ 裆´è... 179 .h> # include <string.stock.. stock = s.

55). } 180 .”. stock = s..exit<b/c/e> .” << stock.int s) { strcpy(name.. Name .101.int c.” << name..201. Code . do { cout << “\nBook. char choice... if (choice != ‘e’) { cout << “\nBorrow/Return <b/r> .. void main() { library_book book.stock. void operator +=(int x) { stock += x.”.class library_cdrom { char name[25].borrow.. cin >> choice. library_cdrom cdrom...cdrom_assign(“Know your Basics”..... Stock . 2.. int code. ROM details .book_assign(“Half Blood Prince”..” << code. 3. public : void cdrom_assign(char n[15].50). } }.n). book. cdrom.cdrom.”.. } void operator -=(int x) { stock -= x.. code = c. } void display() { cout << cout << cout << cout << } “\n “\n “\n “\n CD 1... cin >> borrow.

switch (choice) { case ‘b’: switch (borrow) { case ‘b’ : book += 1. book -= 1. case ‘r’ : cdrom -= 1. cdrom -= 1.break. break. case ‘c’ : switch (borrow) { case ‘b’ : cdrom += 1. cdrom += 1. -= ÝAò ªêòŸ°Pè¬÷Š ðò¡ð´ˆF õö‚èñ£ù ð£EJ™ Iè âOî£è I°‚èŠð´õ¬î»‹. } ËôèˆF½œ÷ Þ¼Š¹èœ. break.break. } book. } } while (choice != ‘e’). å¼ ªêòŸ°P‚°Š ¹Fò ªð£¼¬÷ õöƒ°‹ ªêò™¸†ð«ñ ªêòŸ°PŠ ðEI°Š¹ â¡ø¬ö‚èŠð´Aø¶.. °¬ø‚èŠð´õ¬î»‹ èõQˆb˜è÷£? book += 1. } cdrom.break. break. getch(). õö‚èñ£ù +=.”.break. case ‘e’ : cout << “\nTerminating . 181 . case ‘r’ : book -= 1.display().display().

 ðEI°‚èŠð†ì ªêòŸ°P ãŸA¡ø ªêò«ôŸHèÀœ å¡Á ñ†´ñ£õ¶ ðòù˜ õ¬óòÁˆî îóMùñ£è Þ¼‚è «õ‡´‹. å¼ ªêòŸ°P‚°‚ ôîô£ù ðEè¬÷ õ¬óòÁ‚è º®»‹. int) 182 .  ðEI°‚èŠð†ì ªêòŸ°Pèœ ÜõŸP¡ ªêò«ôŸHè¬÷Š ªð£Áˆîñ†®™ Ü®Šð¬ì„ ªêòŸ°Pè¬÷Š «ð£¡«ø ªêò™ð´A¡øù. Üî£õ¶. max(int. ܶ õ¬óòÁ‚èŠð†´œ÷ Þù‚°¿M¡ ªð£¼÷£è Þ¼‚è «õ‡´‹. ðJŸC Mù£‚èœ I.  àÁŠ¹„ ªêòŸÃÁ Íô‹ Þ¼ñ„ ªêòŸ°P¬òŠ ðEI°‚°‹«ð£¶. ܬõ:  㟪èù«õ Þ¼‚°‹ ªêòŸ°PèÀ‚° ñ†´«ñ ðEI°‚è º®»‹. int.  å¼ ªêòŸ°PJ¡ Ü®Šð¬ì õ¬óò¬ø¬ò ñ£ŸPò¬ñ‚è º®ò£¶. int).  Þ¼ñ„ ªêòŸ°PèO¡ (Binary Operators) ðEI°‚°‹«ð£¶. å«óªò£¼ ªõOŠð¬ì„ ªêò½¼¬ð ñ†´«ñ 㟰‹. W«ö»œ÷ ðEè¬÷ G¬ø«õŸø„ ªêòŸÃÁ ðEI°Š¬ðŠ ðò¡ð´ˆ¶‹ å¼ Gó¬ô ⿶è: Ü) Þó‡´ º¿â‡èO™ ªðKò â‡¬í‚ è‡ìPò¾‹ Ý) Í¡Á º¿â‡èO™ ªðKò â‡¬í‚ è‡ìPò¾‹ M¬ì: ªêòŸÃÁ º¡õ®¾èœ max(int.ªêòŸ°PŠ ðE I°Š¹‚è£ù MFº¬øèœ: ªêòŸ°PèO¡ ðEI°Š¹‚°„ Cô 膴Šð£´èÀ‹ õó‹¹èÀ‹ àœ÷ù. ¹Fò ªêòŸ°Pè¬÷ à¼õ£‚è º®ò£¶. å¼ ªêòŸ°PJ¡ ªêò™ð£†¬ì ñÁõ¬óò¬ø ªêŒò º®ò£¶. Ü„ªêòŸ°PJ¡ ÞìŠð‚è‹ Ü¬ñ»‹ ªð£¼œ.

float power (float. xy ñFŠ¬ð‚ è‡ìPò¾‹. Ý) x.float incr(float). int). ðEI°‚èŠð†ì ªêòŸ°P¬ò õ¬óòÁŠðF™ H¡ðŸø «õ‡®ò ð®G¬ôè¬÷Š ð†®òL´è. M¬ì: ªêòŸÃÁ º¡õ®¾èœ int power(int. W›‚è£μ‹ ðEèÀ‚°Š ðEI°Š¹ ¸†ðˆ¬îŠ ðò¡ð´ˆF„ ªêòŸÃÁè¬÷ â¿î¾‹: Ü) float Þù ñ£PJ¡ ñFŠ¬ð å¡Á I°‚è Ý) char Þù ñ£PJ¡ ñFŠ¬ð å¡Á I°‚è M¬ì: ªêòŸÃÁ º¡õ®¾èœ . VI. float y. void display_Data(). å¼ èôŠ¹ ⇠â¡ð¶ ªñŒŠð°F. c2 â¡Â‹ Þó‡´ ªð£¼œè¬÷‚ Æ®„ ªê£™ô main() ªêò™ÃP¬ù â¿F‚ 裆´è.II. W«ö»œ÷ õ¬óò¬ø¬ò G¬ø¾ ªêŒ¶. char incr(char) III. ðEI°Š¹„ ªêŒòº®ò£î ªêòŸ°Pè¬÷Š ð†®òL´è. VII. y ÝAò Þó‡´‹ float âQ™. float) IV. xy ñFŠ¬ð‚ è‡ìPò¾‹. float imaginary). ªêòŸ°PŠ ðEI°ŠH¡ Ýî£òƒèœ ò£¬õ? V. complex_numbers â¡Â‹ Þù‚°¿M¡ Þó‡´ ªð£¼œè¬÷‚ Æ®„ ªê£™ô Gó™ ⿶è. class complex_numbers { float x. y ÝAò¬õ int âQ™. complex_numbers operator +(complex_numbers n1). } 183 . èŸð¬ùŠ ð°F â¡Â‹ Þó‡´ îó¾ àÁŠ¹è¬÷‚ ªè£‡® ¼‚°‹. ªêòŸÃÁ ðEI°Š¹ Íô‹ W›‚è£μ‹ ðEè¬÷ G¬ø«õŸø C++ ªñ£NJ™ å¼ Gó™ ⿶è: Ü) x. public : void assign_data(float real. complex_numbers ÞùˆF½œ÷ c1.

Ý‚A„ ªêòŸÃÁ Þù‚°¿Š ªð£¼¬÷ˆ (class object) ªî£ìƒA¬õ‚Aø¶ Üî£õ¶.13 11:59:48 +05'30' ð£ì‹ 8 Ý‚AèÀ‹ ÜNŠHèÀ‹ (Constructors and Destructors) 8.h> class simple { private: int a. 8. cout<< “\n Constructor of class-simple “. Üî¡ àÁŠ¹èO™ ªî£ì‚è ñFŠ¹ Þ¼ˆ¶Aø¶. “..com Location: Commercial Taxes Staff Training Institute. Þó‡´ ªêòŸÃÁèÀ«ñ â‰î ñFŠ¬ð»‹ F¼ŠH ÜŠ¹õF™¬ô.8. â‰îˆ îóMùˆ«î£´‹ ªî£ì˜¹¬ìò¬õ Ü™ô. } void getdata() { cout<<“\n Enter values for a and b. ÜNŠH ÝAò Þó‡´ ªêòŸÃÁèÀ«ñ Þù‚°¿M¡ ªðò¬ó«ò ªè£‡´œ÷ù. } 184 .Ramanathan Digitally signed by Ramanathan DN: cn=Ramanathan.03. cout<<“\n The sum of the variables .getdata(). “<<a<<‘\t’<< b.. Ý‚A (constructor) âùŠð´‹ CøŠ¹„ ªêòŸÃÁ Þò‚èŠð´Aø¶. } }. “. cin>>a>>b.Ph:9442282076 Date: 2008. æ˜ Þù‚ °¿Š ªð£¼O¡ ðò¡ð£´ º®¾‚° õ¼‹«ð£¶ ÜNŠH (destructor) âùŠð´‹ CøŠ¹„ ªêòŸÃÁ Þò‚èŠð´Aø¶. c=IN. } void putdata() { cout<<“\nThe two integers .2 Ý‚Aèœ (Constructors) // Program .. o=Commercial Taxed Dept Staff Training Institute. } ~simple() { cout<<“\n Destructor of class – simple .1 º¡Â¬ó æ˜ Þù‚°¿M¡ ꣡Á¼ (instance) ðò¡ð£†´‚° õ¼‹«ð£¶. “<< a+b. public: simple() { a= 0 .b. email=ctdsti@gmail..h> #include<conio.putdata(). b= 0.. s. s.. void main() { simple s. ou=Computer Lecturer. Computer Lecturer. Ý‚A..1 // to determine constructors and destructors #include<iostream.

Ü÷¹¼‚èœ Þ™ô£î Ý‚A Þò‚èŠð´Aø¶.¡ ðò¡ð£´ º®»‹«ð£¶. î£ù¬ñ¾ Ý‚Aèœ Gó™ªðò˜ŠH à¼õ£‚°‹ Ý‚Aèœ (compiler generated constructors) âù‚ °PŠHìŠð´õ¶‡´.. 8. Program. ðòù˜ õ¬óòÁˆî Ý‚Aèœ â¶¾‹ Þ™ô£î«ð£¶ èEŠ ªð£P«ò Þˆî¬èò Ý‚A¬ò à¼õ£‚A‚ ªè£œAø¶.4 Ý‚AJ¡ ðEI°Š¹ (Constructor Overloading) Ý‚Aèœ Þù‚°¿M¡ CøŠ¹„ ªêòŸÃÁèœ â¡ð. 185 . add() â¡Â‹ Ý‚A Ü÷¹¼‚èœ Þ™ô£î Ý‚A (non-parameterized constructor) Ý°‹.. 5 6 The sum of the variables…. Üî£õ¶. î£ù£è«õ Þò‚èŠð´Aø¶..simple .simple … 8. 2) ªð£¼À‚° G¬ùõèˆF™ Þì‹ å¶‚°Aø¶. Ü÷¹¼‚èœ Þ™ô£ñ™ å¼ ªð£¼œ ÜPM‚èŠð´‹«ð£¶.«ñŸè‡ì Gó¬ô„ ªêò™ð´ˆ¶¬èJ™ s â¡Â‹ ªð£¼œ à¼õ£‚èŠð´‹«ð£¶ simple() â¡Â‹ Ý‚A. Üî£õ¶ GóL¡ ªêò™ð£´ º®¾‚° õ¼‹«ð£¶ ~simple() â¡Â‹ ÜNŠH î£ù£è«õ Þò‚èŠð´Aø¶.2 Gó™ Ý‚AŠ ðEI°Š¬ð M÷‚°Aø¶. Þ‰î GóL¡ ªõOf´ Þšõ£Á Þ¼‚°‹: Constructor of class . Þ¶ î£ù¬ñ¾ Ý‚A (default constructor) âùŠ ð´Aø¶. õö‚èñ£è.8. Enter values for a & b… 5 6 The two integers…. 11 Destructor of class . s.3 Ý‚AJ¡ ªêò™ð£´èœ 1) Þù‚°¿Š ªð£¼O¡ àÁŠ¹èO™ ªî£ì‚è ñFŠ¹ Þ¼ˆ¶Aø¶. ªêòŸÃÁ ðEI°Š¹ (Function Overloading) Ý‚AèÀ‚°‹ ªð£¼‰¶‹.

// Program - 8.2
// To demonstrate constructor overloading
# include<iostream.h>
#include<conio.h>
class add
{
int num1, num2, sum;
public:
add()
{
cout<<“\n Constructor without parameters.. “;
num1= 0;
num2= 0;
sum = 0;
}
add ( int s1, int s2 )
{
cout<<“\n Parameterized constructor... “;
num1= s1;
num2=s2;
sum=NULL;
}
add (add &a)
{
cout<<“\n Copy Constructor ... “;
num1 = a.num1;
num2 = a.num2;
sum = NULL;
}
void getdata()
{
cout<<“Enter data ... “;
cin>>num1>>num2;
}
void addition()
{
sum=num1+num2;
}
void putdata()
{
cout<<“\n The numbers are..”;
cout<<num1<<‘\t’<<num2;
cout<<“\n The sum of the numbers are.. “<< sum;
}
};
void main()
{
add a, b (10, 20) , c(b);
a.getdata();
a.addition();
b.addition();
c.addition();
cout<<“\n Object a : “;
a.putdata();
cout<<“\n Object b : “;
b.putdata();
cout<<“\n Object c : “;
c.putdata();
}

186

ªõOf´:
Constructor without parameters….
Parameterized Constructor...
Copy Constructors…
Enter data .. 5 6
Object a:
The numbers are 5 6
The sum of the numbers are ….. 11
Object b:
The numbers are 10 20
The sum of the numbers are … 30
Object c:
The numbers are 10 20
The sum of the numbers are ….. 30

â¡Â‹ Ý‚A Ü÷¹¼ 㟰‹ Ý‚A âùŠ
ð´Aø¶. Þ‰î Ý‚A¬ò„ ªêò™ð´ˆî, Þó‡´ int ñ£PLèœ Ü™ô¶
ñ£PèÀì¡ ªð£¼¬÷ ÜPM‚è «õ‡´‹.
°PŠ¹: char, float, double Ü÷¹¼‚è¬÷»‹ 㟰‹. ܬõ àœÀ¬ø
Þùñ£ŸøˆF¡ è£óíñ£è int îóMùˆ«î£´ ªð£¼‰¶‹ â¡ð ãŸÁ‚
ªè£œ÷Š ðì‚ Ã®ò¬õ«ò.
add(int s1, int s2)

â´ˆ¶‚裆´: add a(10, 60) / add a(ivar, ivar)
add (add &a) â¡Â‹ Ý‚A, ïè™ Ý‚A (copy constructor) âùŠð´Aø¶.

ïè™ Ý‚A W›‚è£μ‹ Åö™èO™ Þò‚èŠð´‹:
1)

ã«î‹ æ˜ àÁŠ¹„ ªêòŸÃP‚° å¼ ªð£¼¬÷
Ü÷¹¼õ£è ÜŠH¬õ‚°‹«ð£¶.
â´ˆ¶‚裆´: void add : : outdata (add x);

2)

æ˜ àÁŠ¹„ ªêòŸÃÁ å¼ ªð£¼¬÷ˆ F¼ŠHòŠ¹‹
«ð£¶.
â´ˆ¶‚裆´: add getdata();

3)

å¼ ªð£¼œ °PŠ¹õ¬è Ü÷¹¼õ£è Ý‚A‚° ÜŠH
¬õ‚èŠð´‹«ð£¶.
â´ˆ¶‚裆´: add a; b(a);

W«ö»œ÷ Gó™ (Program - 8.3) ïè™ Ý‚A ⊫ð£ªî™ô£‹ Þò‚èŠ
ð´Aø¶ â¡ð¬î M÷‚°Aø¶:

187

// Program – 8.3
// To demonstrate constructor overloading
# include<iostream.h>
#include<conio.h>
class add
{
int num1, num2, sum;
public:
add()
{
cout<<“\n Constructor without parameters.. “;
num 1 = 0;
num 2 = 0;
sum
= 0;
}
add ( int s1, int s2 )
{
cout<<“\n Parameterized constructor... “;
num1= s1;
num2=s2;
sum=NULL;
}
add (add &a)
{
cout<<“\n Copy Constructor ... “;
num1= a.num1;
num2=a.num2;
sum = NULL;
}
void getdata()
{
cout<<“Enter data ... “;
cin>>num1>>num2;
}
void addition(add b)
{
sum=num1+ num2 +b.num1 + b.num2;
}
add addition()
{
add a(5,6);
sum = num1 + num2 +a.num1 +a.num2;
}
void putdata()
{
cout<<“\n The numbers are..”;
cout<<num1<<‘\t’<<num2;
cout<<“\n The sum of the numbers are.. “<< sum;
}
};

188

void main()
{
clrscr();
add a, b (10, 20) , c(b);
a.getdata();
a.addition(b);
b = c.addition();
c.addition();
cout<<“\n Object a : “;
a.putdata();
cout<<“\n Object b : “;
b.putdata();
cout<<“\n Object c.. “;
c.putdata();
}

ouput of the above program
Constructor without parameters..
Parameterized constructor...
Copy Constructor ... Enter data ... 2 3
Copy Constructor ...
Parameterized constructor...
Parameterized constructor...
Object a :
The numbers are..2
3
The sum of the numbers are.. 35
Object b :
The numbers are..0
1494
The sum of the numbers are.. 0
Object c..
The numbers are..10
20
The sum of the numbers are.. 41

ïè™ Ý‚A âˆî¬ùº¬ø Þò‚èŠð´Aø¶ â¡ð¬î‚
èõQˆb˜è÷£?
Program - 8.3 GóL™ W›‚è£μ‹ ßÁèœ ïè™ Ý‚A¬ò
Þò‚°A¡øù:

189

Ý‚Aò£ù¶ î£ù£è«õ Þò‚èŠð´‹. // b b = c. ~ â¡Â‹ °P¬òŠ ªðòK¡ º¡ªù£†ì£è‚ ªè£‡®¼‚°‹. GóLÂœ â‰î ÞìˆF™ ÜPM‚èŠð´‹ ªêòŸÃÁèÀ‹ ðEI°‚èŠðì º®»‹ â¡ðîPè. 8. Ü÷¹¼‚èO¡ ð†®ò¬ô‚ ªè£‡®¼‚è º®»‹ 3) Ý‚A„ ªêòŸÃÁ. 190 . ܬö‚è «õ‡®òF™¬ô. Ýù£™. 2) Ý‚A.addition().add c(b).5 Ý‚A õ¬óòÁŠ¹ ñŸÁ‹ ðò¡ð´ˆî½‚è£ù MFº¬øèœ: 1) Ý‚AJ¡ ªðò˜ Þù‚°¿M¡ ªðòó£è«õ Þ¼‚è «õ‡´‹. ðEI°‚èŠðì º®»‹. // addition() â¡Â‹ àÁŠ¹„ ªêòŸÃÁ å¼ ªð£¼¬÷ˆ F¼ŠHòŠ¹Aø¶. 8. 5) æ˜ Þù‚°¿Š ªð£¼œ à¼õ£‚èŠð´‹«ð£¶. a. // b â¡Â‹ ªð£¼œ ªêò½¼ð£è ÜŠH¬õ‚èŠ ð´Aø¶. å¼ ªð£¼¬÷ à¼õ£‚°‹«ð£¶. Gó™ªðò˜ŠH æ˜ Ý‚A¬ò à¼õ£‚A‚ ªè£œÀ‹. â¡Â‹ ªð£¼œ addition() â¡Â‹ àÁŠ¹„ ªêòŸÃP‚° ªêò½¼ð£è ÜŠH¬õ‚èŠð´Aø¶. «ñŸè‡ì â´ˆ¶‚裆®™ addition() â¡Â‹ ªêòŸÃP¡ ðE I°‚èŠð†´œ÷¶ (overloaded). Ý‚Aò£™ ªð£¼À‚ªèù 嶂èŠð´‹ G¬ùõèŠ ð°F¬ò M´M‚°‹ å¼ ªêòŸÃø£°‹. 4) Ý‚A â¬î»‹ ðòù˜ õ¬óòÁ‚è£î«ð£¶.6 ÜNŠHèœ (Destructors) ÜNŠH â¡ð¶.addition(b). Þ¶¾‹ Þù‚°¿M¡ ªðò¬ó«ò ªè£‡®¼‚°‹.

...â´ˆ¶‚裆´: class simple { ..7 ÜNŠH õ¬óòÁŠ¹ ñŸÁ‹ ðò¡ð´ˆî½‚è£ù MFº¬øèœ: 1) ÜNŠHJ¡ ªðòó£ù¶. Gó™ªðò˜ŠH æ˜ ÜNŠH¬ò à¼õ£‚A‚ ªè£œÀ‹.. } } 8..... .. ªêò½¼¹è¬÷ ãŸè£¶..... public : ~simple() { .. 191 . â‰î ñFŠ¬ð»‹ F¼ŠH ÜŠð£¶...... 4) ÜNŠHJ¡ ðEI°‚èŠðì º®ò£¶. 3) ÜNŠH.. ÜNŠH î£ù£è«õ Þò‚èŠð´‹.. Üî£õ¶...... 6) GóL™ à¼õ£‚èŠð†ì æ˜ Þù‚°¿Š ªð£¼O¡ ðò¡ð£´ º®¾‚° õ¼‹«ð£¶....... 5) ðòù˜. 2) ÜNŠH.. ܬö‚è «õ‡®òF™¬ô... ~ â¡ø º¡ªù£†´‚ °P»ì¡ îò Þù‚°¿M¡ ªðò¬ó«ò ªè£‡®¼‚°‹. æ˜ Þù‚°¿M™ æ˜ ÜNŠH ñ†´«ñ Þ¼‚è º®»‹...... ÜNŠH¬ò õ¬óòÁ‚è£î«ð£¶...

} }. class simple { private: int x. void main() { simple s. } simple(int z=5) { x = z. } class simple { private: int x.. } }. simple() { x = 5. public: simple(int y) { x = y. ⊫𣶠Þò‚èŠð´Aø¶? æ˜ Þù‚°¿Š ªð£¼÷£ù¶. void main() { simple s(6). ðEI°Š¹ ꣈Fòñ£? 3. } }. public: simple(int y) { x = y.ðJŸC Mù£‚èœ: I W›‚è£μ‹ ܆ìõ¬í¬ò G¬ø¾ ªêŒè: Mù£‚èœ Ý‚A ÜNŠH 1. â‰î õ¬óªò™¬ô‚°œ (scope) ÜPM‚èŠðì «õ‡´‹? 2.. } 192 . ªêò½¼¹è¬÷ 㟰ñ£? II W›‚è£μ‹ Gó™ð°Fèœ H¬ö²†´õ¶ ã¡? class simple { private: int x. 4..

Ü®Šð¬ì Þù‚°¿M¡ ܬùˆ¶Š ð‡¹è¬÷»‹ ñó¹K¬ñò£èŠ ªðŸÁ M´Aø¶.Ramanathan Digitally signed by Ramanathan DN: cn=Ramanathan. î¼M‚èŠð†ì Þù‚°¿. ܶñ†´I¡P.13 12:00:18 +05'30' ð£ì‹ 9 ñó¹Kñ‹ (Inheritance) 9.. ܶ«ð£ô«õ.Ph:9442282076 Date: 2008..03. ‘ñó¹Kñ‹’ â¡Â‹ ªê£™ ï¬ìº¬ø õ£›‚¬èJ™ ïñ‚° I辋 ÜPºèñ£ù ªê£™. ðì‹ 9. æ˜ Þù‚°¿¾‹ Üî¡ Ü®Šð¬ì (Parent) Þù‚°¿MìI¼‰¶ ð‡¹è¬÷ ñó¹K¬ñò£èŠ ªðÁAø¶.1 º¡Â¬ó å¼ ªð£¼œ«ï£‚° Góô£‚è ªñ£NJ¡ ê‚Fõ£Œ‰î ð‡¹‚ÃÁ ñó¹Kñ‹ (Interitance) Ý°‹. o=Commercial Taxed Dept Staff Training Institute. email=ctdsti@gmail. ñó¹Kñ‹ â¡ð¶ 㟪èù«õ Þ¼‚°‹ Þù‚ °¿‚èO¡ Ü®Šð¬ìJ™ ¹Fò Þù‚ °¿‚è¬÷ à¼õ£‚°‹ ªêò™ º¬ø Ý°‹. c=IN. î¼M‚èŠð†ì Þù‚°¿‚èœ (derived classes) âù¾‹ ܬö‚èŠ ð´A¡øù.1 ñó¹Kñ‹ 193 . °ö‰¬îèœ îñ‚«è àKò ð‡Hò™¹èÀì¡ ªðŸ«ø£K¡ ð‡¹è¬÷ ñó¹ õNò£èŠ ªðÁA¡øù. Ü®Šð¬ì Þù‚°¿‚èœ (base classes) âù¾‹.com Location: Commercial Taxes Staff Training Institute. î¼M‚èŠ ð†ì Þù‚°¿M™ ôîô£ù ð‡¹‚ÃÁè¬÷»‹ õNº¬øè¬÷»‹ «ê˜ˆ¶ Üî¡ ªêòô£Ÿø¬ô ÜFèK‚è º®»‹. Computer Lecturer. Þ¬õ º¬ø«ò. ou=Computer Lecturer.

194 .9. á) î¼M‚èŠð´‹ Þù‚°¿¾‚°Kò Ã´î™ ð‡¹ è¬÷»‹. Ý) class â¡ø ªê£™¬ô Ü´ˆ¶. W›‚è£μ‹ MFº¬øè¬÷Š H¡ðŸø «õ‡´‹: Ü) class â¡Â‹ CøŠ¹„ªê£™ Þ¼‚è «õ‡´‹. ðì‹1-™ 致œ÷ð®. 9. î¼M‚èŠð†ì Þù‚°¿¬õ õ¬óòÁ‚°‹«ð£¶. õ£èù‹ â¡Â‹ Þù‚°¿M¡ ð‡¹‚ÃÁèÀ‹. 3) Þ¬ìºèˆF¡ ºó‡ð£®¡¬ñ (Consistency of Interface). Þ) 埬ø º‚裟¹œO (:) Þ싪ðø «õ‡´‹. Ü®Šð¬ì Þù‚°¿M¡ õNº¬øè¬÷(methods) î¼M‚èŠð†ì Þù‚°¿‚èœ ðA˜‰¶ªè£œ÷ º®»‹. 裘. Ü«î ªêòô£‚è‹ «õ‡ìŠð´A¡ø «õªø£¼ ðò¡ð£†®™ ðò¡ð´ˆF‚ªè£œ÷ º®»‹.3 î¼M‚èŠð†ì Þù‚°¿¾‹ Ü®Šð¬ì Þù‚°¿¾‹ æ˜ Þù‚°¿ML¼‰¶ Hø Þù‚°¿‚èœ î¼M‚èŠð´ñ£J¡ Üî¬ù Ü®Šð¬ì Þù‚°¿ â¡A«ø£‹. Mñ£ù‹. Þ‰î Í¡Á î¼M‚èŠð†ì Þù‚°¿‚èÀ«ñ ºó‡ð£ìŸø Þ¬ìºèƒè¬÷‚ ªè£‡´œ÷ù âùô£‹. public Ü™ô¶ protected ÝAòõŸÁœ âˆî¬èò ÜμAò™¹ì¡ î¼M‚èŠð´Aø¶ âù‚ °PŠHì «õ‡´‹. à) Ü®Šð¬ì Þù‚°¿M¡ ªðò¬ó‚ °PŠHì «õ‡´‹. å¼ ðò¡ð£†´‚ªèù â¿îŠð†ì °P º¬øˆ ªî£°F¬ò. å¼ GÁõùˆF™ ð™«õÁ ðò¡ð£†´ ªñ¡ªð£¼œèœ à¼õ£‚èŠð´A¡øù. Þîù£™ Gó™ à¼õ£‚°‹ «ïó‹ ªõ°õ£è‚ °¬øAø¶. 2) Gó™ °Pº¬øŠ ðA˜¾ (Code Sharing). Ü®Šð¬ì Þù‚°¿M¡ àÁŠ¹è¬÷ˆ î¼M‚èŠð†ì Þù‚°¿ ñó¹K¬ñò£èŠ ªðÁAø¶. ß) private.2 ñó¹KñˆF¡ ðô¡èœ ñó¹Kñ‹ W›‚è£μ‹ ðô¡è¬÷ ÜO‚Aø¶: 1) Gó™ °Pº¬øJ¡ ñÁðòù£‚è‹ (Reusability of Code). î¼M‚èŠð´‹ Þù‚°¿M¡ ªðò˜ Þ싪ðø «õ‡´‹. ñó¹K¬ñò£èŠ ªðÁ‹ ð‡¹‚ ÃÁèÀ‹ õNº¬øèÀ‹ ܬö‚ °‹ õNº¬øèÀ‚° å«ó ñ£FKò£ù Þ¬ìºèˆ¬î«ò õöƒ° A¡øù. õNº¬øè¬÷»‹ õ¬óòÁ‚è «õ‡´‹. ¬ê‚Aœ ÝAò Í¡Á î¼M‚èŠð†ì Þù‚°¿‚èÀ‚°‹ ªð£¶õ£è ܬñ‰¶œ÷ù. õNº¬øèÀ‹.

. } }.h> class add { int sum. 195 . num2.1 #include< iostream. } accept() { cout<<“\n Enter two numbers .h> #include<conio.. public: add() { num1 = num2 = sum = 0. } }. } minus() { add::accept(). protected: int num1. cin>>num1>>num2.// Program .“ << sub. “. } plus() { sum = num1 + num2. cout<<“\n The difference of two numbers are .. class subtract :public add { int sub. cout<<“\n Subtract constructor . “. sub= num1-num2.9.. “. public: subtract() { sub = 0.. “<< sum. cout<<“\n The sum of two numbers is .. cout<<“\n Add constructor .

accept(). î¼M‚èŠð´‹ Þù‚°¿M¡ àÁŠ¹„ ªêòŸÃÁèœ. subtract â¡ð¶ î¼M‚èŠð†ì Þù‚°¿.1..minus(). break. cin>>choice. Subtract . } } Program -9. int choice = 0.plus().\n2. } Program. Add.9. case 2: s.1.. switch(choice) { case 1: s. cout<<“\n Enter your choice “. î¼M‚èŠð†ì Þù‚°¿ Þšõ£Á õ¬óòÁ‚èŠ ðì «õ‡´‹: class < ªðò˜> : < ÜμAò™¹> < Ü®Šð¬ì Þù‚°¿M¡ ªðò˜> { î¼M‚èŠð´‹ Þù‚°¿M¡ îó¾ àÁŠ¹èœ. cout<<“\n1.”. s.™ add â¡ð¶ Ü®Šð¬ì Þù‚°¿.™ substract â¡Â‹ î¼M‚èŠð†ì Þù‚°¿ Þšõ£Á õ¬óòÁ‚èŠð†´œ÷¶: Ü®Šð¬ì Þù‚°¿ 裇¹ G¬ô/ ÜμAò™¹ î¼M‚èŠð´‹ Þù‚°¿ î¼M‚èŠð´‹ Þù‚°¿M¡ àÁŠ¹èœ Ü®Šð¬ì Þù‚°¿M¡ àÁŠ¹„ ªêòŸÃP¬ù ܬö‚°‹ ßÁ 196 . break.void main() { subtract s.

private ÜμAò™¹ ªè£‡ì àÁŠ¹è÷£è ñó¹õN ªðøŠ ð´Aø¶.4 裇¹G¬ôŠ 𣃰 / ÜμAò™¹ õ¬óòÁŠH (Visibility Mode / Accessibility Specifier) ñó¹KñˆF¡ °PŠHìˆî‚è ÃÁ â¡ùªõQ™. Ü®Šð¬ì Þù‚°¿M¡ àÁŠ¹èœ private àÁŠ¹èœ protected àÁŠ¹èœ î¼M‚èŠð†ì Þù‚°¿ private protected public ñó¹K¬ñò£èŠ ªðøŠð´õF™¬ô. âŠð®Š ðò¡ð´ˆF‚ ªè£œ÷ «õ‡´‹ â¡ð¶î£¡. Ýù£½‹ ܬõ ªî£ì˜‰¶ Gô¾‹. ÜμAò™¹ (accessibility) âùŠð´Aø¶. Ü®Šð¬ì Þù‚°¿ àÁŠ¹èO¡ õ¬óªò™¬ô ñŸÁ‹ ÜμAò™¬ð ܆ìõ¬í 9.1 î¼M‚èŠð†ì Þù‚°¿M™ Ü®Šð¬ì Þù‚°¿ àÁŠ¹èO¡ õ¬óªò™¬ô»‹ ÜμAò™¹‹ 197 .9. î¼M‚èŠð†ì Þù‚ °¿M¡ ªð£¼œèÀ‹ àÁŠ¹èÀ‹ Ü®Šð¬ì Þù‚°¿M¡ àÁŠ¹ è¬÷ ⊫ð£¶. î¼M‚èŠð†ì Þù‚ °¿M™. protected protected ÜμAò™¹ ªè£‡ì àÁŠ¹è÷£è ñó¹õN ªðøŠ ð´Aø¶. ÜμAò™¹ ªè£‡ì àÁŠ¹ è÷£è«õ ªðøŠ ð´Aø¶. º¡Qò™ð£ù 裇¹G¬ôŠ 𣃰 private Ý°‹. public. public private protected public àÁŠ¹èœ ÜμAò™¹ ªè£‡ì àÁŠ¹è÷£è ñó¹õN ªðøŠð´Aø¶. ÜμAò™¹ î‚è ¬õˆ¶‚ ªè£œ÷Š ð´Aø¶. private. ܆ìõ¬í 9. Þ¶«õ. protected âù Í¡Á ÜμAò™¹ õ¬óòÁŠHèœ àœ÷ù.1 M÷‚°A¡ø¶. ÜμAò™¹ ªè£‡ì àÁŠ¹è÷£è ñó¹õN ªðøŠ ð´Aø¶. ÜμAò™¹ õ¬ó òÁŠH¬ò 裇¹G¬ôŠ 𣃰 (visibility mode) â¡Á‹ Ãøô£‹.

Ü®Šð¬ì Þù‚°¿M¡ public ñŸÁ‹ protected àÁŠ¹èœ. minus(). private âù âŠð®ˆ î¼M‚èŠð†ì£½‹ Ü®Šð¬ì Þù‚°¿M¡ private àÁŠ¹èœ î¼M‚èŠð†ì Þù‚°¿M™ ñó¹K¬ñò£èŠ ªðøŠð´õF™¬ô. æ˜ Ü®Šð¬ì Þù‚°¿ protected â¡Â‹ ÜμAò™¹ì¡ î¼M‚èŠ ð´‹«ð£¶. Ýù£™ ÜõŸ¬ø Üμè º®ò£¶.™ add. protected : int num1.1. subtract ÝAò Þù‚°¿‚èœ Þšõ£Á ÜPM‚èŠ ð†´œ÷ù: class add { private: int sum. î¼M‚èŠð´‹ Þù‚°¿M™ protected àÁŠ¹è÷£è¾‹. Program -9. î¼M‚èŠð´‹ Þù‚°¿M™ protected àÁŠ¹è÷£è Gô¾A¡øù. î¼M‚èŠð´‹ Þù‚°¿M™ private àÁŠ¹è÷£è«õ Gô¾A¡øù. public àÁŠ¹èœ public àÁŠ¹ è÷£è¾‹ Gô¾A¡øù. Ü®Šð¬ì Þù‚°¿M¡ protected ñŸÁ‹ public àÁŠ¹èœ. 198 . Ü®Šð¬ì Þù‚°¿‚èœ public. plus(). num2. class subtract : private add { int sub. protected. î¼M‚èŠð†ì Þù‚°¿M™ ܬõ Gô¾‹. public: subtract().æ˜ Ü®Šð¬ì Þù‚°¿ private â¡Â‹ ÜμAò™¹ì¡ î¼M‚èŠ ð´‹«ð£¶. æ˜ Ü®Šð¬ì Þù‚°¿ public â¡Â‹ ÜμAò™¹ì¡ î¼M‚èŠ ð´‹«ð£¶. }. }. Ü®Šð¬ì Þù‚°¿M¡ protected àÁŠ¹èœ. accept(). public: add().

subtract Þù‚°¿ ñó¹õNŠ ªðŸø îó¾ àÁŠ¹èÀ‹.subtract. î¼M‚èŠð†ì Þù‚°¿M™ ñó¹õN ªðøŠð´õF™¬ô. 199 .™ Þ¬õ private Ü®Šð¬ì Þù‚°¿ àÁŠ¹èO¡ ÜμAò™¹ ܆ìõ¬í 9. Ýù£™. î¼M‚èŠð†ì Þù‚ °¿M™ å¼ ê£¡Á¼ (instance) à¼õ£‚èŠð´‹«ð£¶ ºîL™ Þò‚èŠ ð´A¡øù. plus() .2-™ îóŠð†´œ÷ù.™ Þ¬õ private accept(). Ü®Šð¬ì Þù‚°¿M¡ Ý‚Aèœ (constructors). àÁŠ¹„ ªêòŸÃÁèÀ‹: int num1 & num2 .subtract.

™ ÜPM‚èŠð†´œ÷ ªð£¼œè¬÷ «ï£‚°è. 200 . num2 accept().3 ªð£¼œèO¡ îó¾/ ªêòŸÃÁ àÁŠ¹èœ Þò‚èŠð´‹ Ý‚Aèœ:--------------------. private mode of inheritance sub protected: num1. num2 public: accept().2 Ü®Šð¬ì Þù‚°¿ àÁŠ¹èO¡ ÜμAò™¹ Program . subtract() minus(). ----------------------.91. plus(). public: subtract() minus() protected mode of inheritance sub protected: num1.class subtract II III private: private: private: sub num1 num2 accept() plus() public: subtract() minus(). Þ‰î GóL¡ Ü®Šð¬ìJ™ W›‚è£μ‹ ܆ìõ¬í¬ò G¬ø¾ ªêŒè: Þù‚°¿M¡ ªð£¼œèœ îó¾ àÁŠ¹èœ õNº¬øèœ/ ªêòŸÃÁèœ add subtract ܆ìõ¬í 9. plus(). public mode of inheritance ܆ìõ¬í 9.

«ñô£÷˜ 2) ðôõN ñó¹Kñ‹ (Multiple Inheritance) å¡Á‚° «ñŸð†ì Ü®Šð¬ì Þù‚°¿‚èOL¼‰¶ î¼M‚èŠð†ì Þù‚°¿¬õ à¼õ£‚°õ¶ ðôõN ñó¹Kñ‹ Ý°‹.9.Employee . Base ClassÞù‚°¿: Ü®Šð¬ì ºèõK Address Ü®Šð¬ì Base classÞù‚°¿: – Office ܽõôè‹ î¼M‚èŠð†ì Derived Class .5 ñó¹KñˆF¡ õ¬èèœ î¼M‚èŠð†ì Þù‚°¿‚è¬÷ Ü®Šð¬ìò£è‚ ªè£‡´ ¹Fò Þù‚ °¿‚è¬÷ˆ î¼M‚è º®»‹. Þù‚°¿ BaseÜ®Šð¬ì class . 𮺬ø ñó¹Kñ‹.ðEò£œ î¼M‚èŠð†ì Derived Class .Þù‚°¿: Manager «ñô£÷˜ 201 . èôŠ¹ ñó¹Kñ‹.Þù‚°¿ Manager . ðôG¬ô ñó¹Kñ‹. ñó¹KñˆF™ ðôõ¬è àœ÷ù: å¼õN ñó¹Kñ‹. ðôõN ñó¹Kñ‹. 1) å¼õN ñó¹Kñ‹ (Single Inheritance) å«óªò£¼ Þù‚°¿¬õ Ü®Šð¬ìò£è‚ ªè£‡´ î¼M‚èŠ ð†ì Þù‚°¿¬õ à¼õ£‚°õ¶ å¼õN ñó¹Kñ‹ Ý°‹.

2 GóL¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? 202 .3) ðôG¬ô ñó¹Kñ‹ (Multilevel Inheritance) î¼M‚èŠð†ì æ˜ Þù‚°¿¬õ Ü®Šð¬ìò£è‚ ªè£‡´ Þ¡ªù£¼ î¼M‚èŠð†ì Þù‚°¿¬õ à¼õ£‚°õ¶ ðôG¬ô ñó¹Kñ‹ Ý°‹.9. Ü®Šð¬ì Þù‚°¿: î£ˆî£ î¼M‚èŠð†ì Þù‚°¿ : î î¼M‚èŠð†ì Þù‚°¿ : °ö‰¬î Program .

.”...h> class base { public: base() { cout<<“\nConstructor of base class.”. class derived:public base { public : derived() { cout << “\nConstructor of derived ..h> #include<conio. “.// Program .”.9.. “... } 203 ... } }. } }... } ~derived() { cout << “\nDestructor of derived2 .2 #include<iostream.. void main() { derived2 x. class derived2:public base { public : derived() { cout << “\nConstructor of derived2 .”. } ~base() { cout<<“\nDestructor of base class. } ~derived() { cout << “\nDestructor of derived . } }..

ñó¹Kñ‹ ªðŸø Þù‚°¿‚èO¡ õK¬êJ™ Þò‚èŠð´A¡øù. protected: void get(). Constructor of derived2 … Destructor of derived2… Destructor of derived Destructor of base class . ܆ìõ¬í -4. void getb(). }. public: void read(). class type : public node { int a.ªõOf´: Constructor of base class… Constructor of derived …. void init().. ÜNŠHèœ º¡H¡ õK¬êJ™ Þò‚èŠð´‹. protected: int b. Hø Þù‚°¿‚è¬÷ˆ î¼MŠðîŸè£è ñ†´«ñ ðò¡ð´‹ Þù‚ °¿‚èœ Ü¼õ Þù‚°¿‚èœ Ü™ô¶ 輈Fò™ Þù‚°¿‚èœ (Abstract Classes) âùŠð´A¡øù. public: void func1(). Ü®Šð¬ì Þù‚°¿M™ ªî£ìƒA ÞÁFò£èˆ î¼M‚èŠð†ì Þù‚°¿ õ¬óJ™. Üî£õ¶. 輈Fò™ Þù‚°¿‚èO™ ªð£¼œè¬÷ à¼õ£‚è º®ò£¶.5. Üî£õ¶.  Ý‚Aèœ. ðJŸC Mù£‚èœ 1) W›‚è£μ‹ õ¬óòÁŠ¹è¬÷ Ü®Šð¬ìò£è‚ ªè£‡´. } 204 .6 ÝAòõŸ¬ø G¬ø¾ ªêŒè: class node { int x.

class statement :private type { int p. protected: void func3(). type Þù‚°¿M¡ àÁŠ¹èœ àÁŠ¹èO¡ ÜμAò™¹ private protected public type Þù‚°¿M™ ñó¹õNŠ ªðŸø àÁŠ¹èœ type Þù‚°¿M™ õ¬óòÁ‚èŠ ð†ì¬õ ܆ìõ¬í 4 type Þù‚°¿ statement Þù‚°¿M¡ àÁŠ¹èœ àÁŠ¹èO¡ ÜμAò™¹ private protected public statement Þù‚ °¿M™ ñó¹õNŠ ªðŸø àÁŠ¹èœ statement Þù‚ °¿M™ õ¬ó òÁ‚èŠð†ì¬õ ܆ìõ¬í 5 statement Þù‚°¿ ªð£¼œèœ Üμ躮»‹ àÁŠ¹èœ îó¾ àÁŠ¹èœ àÁŠ¹„ ªêòŸÃÁèœ type Þù‚°¿ statement Þù‚°¿ ܆ìõ¬í -6 ªð£¼œèœ 205 . public: void func2(). }.

int). b1 = a1.a3 = 0. der. protected : int passenger.2) W›‚è£μ‹ GóL™ àœ÷ H¬öè¬÷„ ²†®. è£óí‹ ÃÁè: #include<iostream. b2 . der.h> class A { private : int a1. public: void inputdata( int. void main() { B der. }. 206 . b3.func(). public: int a2. }. } }. void outputdata(). W¿œ÷ Mù£‚èÀ‚° M¬ì î¼è: class vehicle { int wheels. class B : public A { public: void func() { int b1. b3 = a3. protected: int a3. b2 = a2. } 3) W›‚è£μ‹ ÜPMŠ¹è¬÷ «ï£‚°è.

vehicle â¡Â‹ Þù‚°¿M¡ Ü®Šð¬ì Þù‚°¿¬õ»‹ î¼M‚èŠð†ì Þù‚°¿¬õ»‹ °PŠH´è. }. protected: int load. public: student ( int a. int b) { m1 = a.. heavy.h> class student { int m1. Ü. bus Þù‚°¿M¡ ªð£¼œ. displaydata() â¡Â‹ ªêòŸÃÁ Íô‹ Üμè º®Aø îó¾ àÁŠ¹è¬÷‚ °PŠH´è. cout<<“\n Non parameterized constructors. void writedata(). m2. Ý. W›‚è£μ‹ GóL¡ ªõOf´ â¡ùõ£è Þ¼‚°‹? #include<iostream. public: void fetchdata( char ). }. }. class bus: private _heavy_vehicle { char marks[20]. outputdata() â¡Â‹ ªêòŸÃP¬ù.class heavy_vehicle : protected vehicle { int diesel_petrol. } 207 .h> #include<conio. m2 = b. heavy_vehicle Þù‚°¿M¡ ß.”. Üμè º®Aø îó¾ àÁŠ¹è¬÷‚ °PŠH´è. total. void displaydata(). ªð£¼œè÷£™ Üμè º®»ñ£? 4. public: void readdata( int. int). Þ.

Sign up to vote on this title
UsefulNot useful