USER-DEFINED FUNCTIONS IN C++ C++ programming-ல் programmer ……
USER-DEFINED FUNCTIONS IN C++
User-Defined Function என்பது programmer தன் தேவைக்கேற்ப define செய்யும் ஒரு named block of code. ஒரே code-ஐ பல இடங்களில் மீண்டும் எழுதாமல், ஒரு function ஆக உருவாக்கி தேவையான இடங்களில் call செய்யலாம். Simple Definition A user-defined functi…
User-Defined Function என்பது programmer தன் தேவைக்கேற்ப define செய்யும் ஒரு named block of code. ஒரே code-ஐ ப……
ஒரு program-ல் இரண்டு numbers-ஐ பல முறை add செய்ய வேண்டும் என்று வைத்துக்கொள்வோம். ஒவ்வொரு முறையும்: sum = a ……
பெரிய program முழுவதையும் main() function-க்குள் எழுதினால் program மிகவும் பெரியதாகவும் புரிந்துகொள்ள கடினமாக……
ஒரு User-Defined Function-க்க……
1. Function Declaration ↓ 2. Functi……
Function program-ல் எப்படி இருக்கும் என்பதை compiler-க்கு முன்கூட்டியே தெரிவிப்பது. இதனை: Function Prototype ……
FUNCTION CALL
Function-ஐ execute செய்ய அழைப்பது Function Call. add(……
FUNCTION DEFINITION
Function என்ன வேலை செய்ய வேண்டும் என்பதை எழுதும் a……
int add(int, int);…
return 0; } int add(int a, in……
return c; }…
Program Start ↓ main() ↓ add(10,20) call ↓ Control goes to add(……
Function Name
Function-க்கு நாம் கொடுக்கும்……
add() இதில்: add என்பது funct……
Return Type
Function எந்த data type value-ஐ தி……
Function integer value return செய்யும். Other examples: float calculate(); char grad……
இங்கு function எந்த result-ஐயும் return செய்யவில்லை. PARAMETERS Function definition-ல் பயன்படுத்தப்படும் vari……
int add(int a, int b) a, b → parameters. add(5, 6); 5, 6 → arguments. TYPES……
No arguments + No return value
Arguments + No return value
No arguments + Return value
Arguments + Return value
TRB / NET / SET / Interview-க்கு மிகவும் முக்கியமான classificati……
return 0; }…
Function arguments பெறும். ஆன……
return 0; }…
இங்கு: add(10,20) values function-க்கு செல்கின்றன. ஆனால் result main()-க்கு return செய்யப்படவி……
return a + b; }…
return 0; }…
இது மிகவும் common மற்றும் useful t……
int add(int a, int b) { retur……
return 0; }…
NN YN NY YY அதாவது: No No Yes No No Yes Yes Yes RETURN ST……
return a + b; இதில் a+b result caller-க்கு திருப்பி அனுப்பப்……
cout execute ஆகாது. ஏனெனில்: return 10; execute……
இங்கு: main() → Calling Function add() → Called Function அதாவது: யார் அழைக்கிறாரோ = Calling……
இதைக் define மட்டும் செய்தால்……
return 0; }…
ஒரே function-ஐ பல முறை call ச……
இதுதான் function reusability. MULTIPLE U……
int add(int a, int b) { return a + b; } int subtra……
return 0; }…
Function definition main()-க்கு கீழே இருந்தால் comp……
int add(int, int); Full progr……
int add(int, int);…
return 0; } int add(int a, int b) { return a + b; } WITHOUT F……
int add(int a, int b) { retur……
return 0; } இது valid. LOCAL VARIABLES……
x variable display() function……
இது error. ஏனெனில் x display function-ன் local variable……
int x = 100;…
return 0; } x பல functions-லும் accessible. FUNCTION N……
C++ standard nested function definition-ஐ suppo……
இது valid. FUNCTIONS CAN CALL……
return 0; } Flow: main() ↓ first() ↓ ……
Code Reusability
ஒரே function-ஐ பல முறை பயன்பட……
Modularity
Large program-ஐ small modules……
Easy Debugging
Problem எந்த function-ல் உள்ள……
Easy Maintenance
ஒரு function-ல் மட்டும் chang……
Readability
Program structure clear ஆக இர……
Reduces Code Duplication
Repeated code குறைகிறது.…
Team Development
Different programmers differe……
Function call செய்யாமல் இருப்……
Wrong number of arguments int……
Function இரண்டு arguments எதி……
Wrong return type int test() { retu……
Missing return value int add(……
Semicolon in function definition Wrong: int add(int a, int b); { return……
Function declaration: int add(int, int); Semicolon வேண்டும். Functio……
User-defined function-ஐ இந்த sequence-ல் நினைவில் வைத்துக்கொள்ளுங்கள்: D → C → D Declarati……
Question: Programmer creates a……
Function declaration is also ……
Actual values passed during a……
Variables listed in function ……
A function that returns no va……
Can a function return more than one value directly? Normally a function has one direct return sta……
Can main() call a user-define……
Can a user-defined function cal……
ஆனால் base condition இல்லையென……
User-defined function is crea……
Function prototype is used to:…
Which keyword represents no r……
Values passed during function……
Parameters appearing in funct……
Which symbol follows a functi……
Which of the following improv……
Write user-defined functions to: Add two numbers Subtract two numbers Multiply two numbers Find squar……
User-Defined Function | ├── Created by programmer | ├── Function Declaration | ├── Function Call | └── Functi……