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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

A-=2 A=A–2 A. 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. b=6.W«ö»œ÷ è†ì¬÷ˆ ªî£°FJ™. ñFŠ¹ 20.J™ Þ¼ˆîŠð´‹ A=A*4 A. b = 10.9-™ 裇è. a=5.J™ Þ¼ˆîŠð´‹ A= A%2 ñFŠ¹ 1.7.J™ Þ¼ˆîŠð´‹ ñFŠ¹ 2. 2.2. ܬùˆ¶ ñFŠH¼ˆ¶ ªêòŸ°P è¬÷»‹ W«ö»œ÷ ܆ìõ¬í 2.J™ Þ¼ˆîŠð´‹ A *= 4 ñFŠ¹ 7. ñFŠH¼ˆ¶ ªêòŸ°Pèœ 28 . A %= 2 A.5 ñFŠH¼ˆ¶ ªêòŸ°Pèœ (Assignment Operators) = â¡ð¶ ê£î£óí ñFŠH¼ˆ¶ ªêòŸ°P Ý°‹. M¬ì¬ò å¼ ñ£PJ™ (ªêòŸ°P J¡ ÞìŠð‚è‹ Þ¼‚°‹) Þ¼ˆ¶õ Þ¶ ðò¡ð´ˆîŠð´Aø¶.J™ Þ¼ˆîŠð´‹ ñFŠ¹ 3. å¼ «è£¬õJ¡ (ªêòŸ°PJ¡ õôŠð‚è‹ Þ¼‚°‹). x â¡Â‹ ñ£PJ™ Þ¼ˆîŠð´‹ ñFŠ¹ â¡ùªõ¡Á ªê£™ô º®»ñ£? a = 10. A. x = (a<b)? a*a : b%a.9. ñFŠ¬ðŠ ªðÁAø¶ A += 2 A += 2 â¡ðî¡ ªð£¼œ A = A +2 Ý°‹. «è£¬õ ªêòô£‚è‹ M¬ì A=5 A â¡Â‹ ñ£PJ™ 5â¡Â‹ ñ£P 5 â¡Â‹ ñFŠ¹ Þ¼ˆîŠð´Aø¶.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

4 x 10-38to 3.15 ð‡¹í˜ˆFèÀì¡ îóMùƒèœ ²†´ ñ£Pè¬÷ ÜPMˆî™ int * iptr.535 -32.483. ²†´ ñ£PJ¡ ªðò˜ Þ‰î ñ£P.147. int * iptr â¡Â‹ ÜPMŠ¹‚ ßÁ‚°.147.483.768 to 32. iptr â¡ð¶ int Þùˆ¬î„ ²†´‹ å¼ ²†´ ñ£P (pointer variable) â¡Á ªð£¼œªè£œ÷ «õ‡´‹.294.1 x 104932 ܆ìõ¬í 2. int Þù ñFŠ¹èœ Þ¼ˆF¬õ‚èŠð†´œ÷ å¼ ºèõK¬ò ñ†´‹ iptr ñ£P 㟰‹. ²†´ Þùˆ¬î„ «ê˜‰î¶ â¡ð¬î Gó™ªðò˜ŠH‚° à혈¶Aø¶ (ñ£P å¼ ºèõK¬ò 㟰‹) Þ‰î„ ²†´ æ˜ int Þùˆ îó¬õ„ ²†´Aø¶ â¡ð¬î‚ °P‚Aø¶.7 x 10-308to 1. 45 .767 0 to 4.768 to 32.647 3.295 -2.767 0 to 65.767 -32.648 to 2.967.î°Fò£‚AèÀ‹ ð‡¹í˜ˆFèÀ‹ ðò¡ð´ˆ¶‹«ð£¶ H† â‡E‚¬è»‹ ñFŠH¡ õó‹ªð™¬ô»‹ ñ£ŸPò¬ñ‚èŠð´‹ îóMùƒè¬÷ ܆ìõ¬í 2.4 x 10-4932 to 1.768 to 32.7 x 10308 3.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.4 x 1038 1.

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

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

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

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

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

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

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

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

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

• î¬ôŠ¹‚ «è£Š¹, º¡õ¬óòÁ‚èŠð†ì ªêò™ÃÁè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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful