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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2-™ 裇è: C++Data îóMùƒèœ C++ Types ðòù˜ õ¬óòÁŠð¬õ User Defined type 膴¼(Structure) Structure Æ´¼(Union) Union Þù‚°¿ (Class) Class â‡μ¼ (Enumeration) Enumeration º¿â‡ Integral typeõ¬è int àœO¬í‰î¬õ Built .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 . ܬõ ãŸA¡ø ñFŠ¹è¬÷»‹ õ¬óòÁˆ¶‚ªè£œ÷ õ¬è ªêŒòŠð†´œ÷¶.3.2 C++ îóMùƒèœ 2.1 ðòù˜ õ¬óòÁ‚°‹ îóMù‹ (User defined data type) Góô˜ î¡Â¬ìò ªê£‰îˆ îóMùƒè¬÷»‹.• Gó™è¬÷ à¼õ£‚°‹ Góô˜ 嚪õ£¼ îóMùˆ¶‚°‹ ãŸø ªêòŸ°Pè¬÷Š ðò¡ð´ˆF‚ªè£œ÷ º®»‹. îóMùƒè¬÷ ºŠªð¼‹ õ¬èJùƒè÷£èŠ HK‚èô£‹: • • • ðòù˜ õ¬óòÁ‚°‹ îóMù‹ (User defined type) àœO¬í‰î îóMù‹ (Built-in type) î¼M‚èŠð†ì îóMù‹ (Derived type) «ñŸè‡ì ðó‰î õ¬èŠð£†®¬ù à†HK¾è«÷£´ ðì‹ 2. å¼ GóL¡ 𮊪ðO¬ñ¬ò (readability) «ñ‹ð´ˆî Þ¶ àî¾Aø¶.

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

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

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

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

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

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

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

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

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

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

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

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

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

768 to 32. ²†´ Þùˆ¬î„ «ê˜‰î¶ â¡ð¬î Gó™ªðò˜ŠH‚° à혈¶Aø¶ (ñ£P å¼ ºèõK¬ò 㟰‹) Þ‰î„ ²†´ æ˜ int Þùˆ îó¬õ„ ²†´Aø¶ â¡ð¬î‚ °P‚Aø¶.967. iptr â¡ð¶ int Þùˆ¬î„ ²†´‹ å¼ ²†´ ñ£P (pointer variable) â¡Á ªð£¼œªè£œ÷ «õ‡´‹. int Þù ñFŠ¹èœ Þ¼ˆF¬õ‚èŠð†´œ÷ å¼ ºèõK¬ò ñ†´‹ iptr ñ£P 㟰‹.294.147.1 x 104932 ܆ìõ¬í 2.768 to 32.767 0 to 4.4 x 10-38to 3. 45 .648 to 2.î°Fò£‚AèÀ‹ ð‡¹í˜ˆFèÀ‹ ðò¡ð´ˆ¶‹«ð£¶ H† â‡E‚¬è»‹ ñFŠH¡ õó‹ªð™¬ô»‹ ñ£ŸPò¬ñ‚èŠð´‹ îóMùƒè¬÷ ܆ìõ¬í 2.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.767 -32.647 3.7 x 10308 3. int * iptr â¡Â‹ ÜPMŠ¹‚ ßÁ‚°. ²†´ ñ£PJ¡ ªðò˜ Þ‰î ñ£P.4 x 1038 1.295 -2.147.483.4 x 10-4932 to 1.535 -32.767 0 to 65.7 x 10-308to 1.15 ð‡¹í˜ˆFèÀì¡ îóMùƒèœ ²†´ ñ£Pè¬÷ ÜPMˆî™ int * iptr.483.768 to 32.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// Program – 3. } cout << “\nSum :” << sum. for (ctr =1. getch(). ctr = 1. ctr <5. } cout << “\nSum :” << sum. for(.) { sum += ctr.18 # include <iostream.19 # include <iostream. char ch =’y’. int sum =0.h> # include <conio. ctr++). ctr = ctr + 1. âù«õ. } ªõ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 <= 5. cout << sum. ctr = 1.ch == ‘y’. int sum =0. } // Program – 3. cin >> ch.h> void main() { clrscr(). getch(). 83 . ctr++. cout << “\nChoice : “ << ch. è£óí‹ â¡ùªõ¡Á ¹KAøî£? for() ߬ø Ü´ˆ¶ ܬ󊹜O ÞìŠð†´œ÷¶.h> # include <conio. cout <<“\nContinue <y/n> ? ”. sum + = ctr â¡Â‹ è†ì¬÷. sum = 0. Þî¡ ªõOf´ 5 âù‚ 裆´‹. ñì‚A¡ àìŸð°Fò£è‚ è¼îŠðìM™¬ô.) { sum += ctr. sum += ctr.h> void main() { clrscr(). for(.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. 6. 7. 4. 2. 1. 3}. â´ˆ¶‚裆ì£è. 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 . 7.Þ¼ðKñ£í ÜEJ¡ G¬ùõè‚ ªè£œ÷÷¾ Þšõ£Á èí‚AìŠð´Aø¶: àÁŠªð‡E‚¬è x æ˜ àÁŠ¹‚°ˆ «î¬õò£ù G¬ùõè Ü÷¾. 6. 8.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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().class statement :private type { int p. protected: void func3().

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

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

Sign up to vote on this title
UsefulNot useful