https://www.rakeshmgs.in/search/label/Template
https://www.rakeshmgs.in


๐ŸŒž เค†เคช เคธเคญी เคตिเคœिเคŸเคฐ्เคธ เค•ो เค›เค  เคฎเคนाเคชเคฐ्เคต เค•ी เคนाเคฐ्เคฆिเค• เคถुเคญเค•ाเคฎเคจाเคं ๐Ÿ™๐ŸŒผ

RakeshMgs

Types of User Defined Functions in C Programming Hindi Notes

Updated:

Type of User-defined Functions in C

user-defined function เค•े 4 เคตिเคญिเคจ्เคจ เคช्เคฐเค•ाเคฐ เคนो เคธเค•เคคे เคนैं, เคตे เคนैं:

1. Function with no arguments and no return value
2. Function with no arguments and a return value
3. Function with arguments and no return value
4. Function with arguments and a return value

Below, we will discuss about all these types, along with program examples.

Function with no arguments and no return value

เคเคธे function เค•ा เค‰เคชเคฏोเค— เคฏा เคคो เคœाเคจเค•ाเคฐी เคช्เคฐเคฆเคฐ्เคถिเคค เค•เคฐเคจे เค•े เคฒिเค เค•िเคฏा เคœा เคธเค•เคคा เคนै เคฏा เคตे เคชूเคฐी เคคเคฐเคน เคธे user เค‡เคจเคชुเคŸ เคชเคฐ เคจिเคฐ्เคญเคฐ เคนोเคคे เคนैं।

เคจीเคšे เคเค• function เค•ा เคเค• เค‰เคฆाเคนเคฐเคฃ เคนै, เคœो user เคธे เค‡เคจเคชुเคŸ เค•े เคฐूเคช เคฎें 2 เคจंเคฌเคฐ เคฒेเคคा เคนै, เค”เคฐ display เค•เคฐเคคा เคนै เคœो greater number เคนै।

    
#include <stdio.h> void greatNum();// function declaration int main() { void greatNum();// function call return 0; } void greatNum()// function definition { int i,j; printf("Enter 2 numbers that you want to compare.."); scanf("%d%d", &i, &j); if(i > j) { printf("The greater number is: %d",i); } else{ printf("The greater number is: %d",j); } }

Function with no arguments and a return value

เคนเคฎเคจे function เค•ो modified เคฌเคจाเคจे เค•े เคฒिเค เค‰เคชเคฐोเค•्เคค เค‰เคฆाเคนเคฐเคฃ เค•ो เคธंเคถोเคงिเคค เค•िเคฏा เคนै greatNum() 2 เค‡เคจเคชुเคŸ numbers เคฎें เคธे เคœो number เค…เคงिเค• เคนै เค‰เคธे return เค•เคฐें।

    
#include <stdio.h> int greatNum();// function declaration int main() { int result; result =greatNum();// function call printf("The greater number is: %d",result); return 0; } int greatNum()// function definition { int i,j,greaterNum; printf("Enter 2 numbers that you want to compare.."); scanf("%d%d", &i, &j); if(i > j) { greaterNum = i; } else{ greaterNum = j; } // returning the result return greaterNum; }

Function with arguments and no return value

เคนเคฎ เคเค• เคนी function เค•ो เคเค• เค‰เคฆाเคนเคฐเคฃ เค•े เคฐूเคช เคฎें, เคฌाเคฐ-เคฌाเคฐ เค‰เคชเคฏोเค— เค•เคฐ เคฐเคนे เคนैं, เคฏเคน display เค•เคฐเคจे เค•े เคฒिเค เค•ि เค•िเคธी เคธเคฎเคธ्เคฏा เค•ो เคนเคฒ เค•เคฐเคจे เค•े เคฒिเค เค•เคˆ เค…เคฒเค—-เค…เคฒเค— เคคเคฐीเค•े เคนो เคธเค•เคคे เคนैं।

เค‡เคธ เคฌाเคฐ, เคนเคฎเคจे function เค•ो modified เคฌเคจाเคจे เค•े เคฒिเค เค‰เคชเคฐोเค•्เคค เค‰เคฆाเคนเคฐเคฃ เค•ो เคธंเคถोเคงिเคค เค•िเคฏा เคนै greatNum() เคฆो int values เค•ो เคคเคฐ्เค• เค•े เคฐूเคช เคฎें เคฒें, เคฒेเค•िเคจ เคฏเคน เค•ुเค› เคญी return เคจเคนीं เค•เคฐेเค—ा।

    
#include <stdio.h> void greatNum(int a, int b);// function declaration int main() { int i,j; printf("Enter 2 numbers that you want to compare.."); scanf("%d%d", &i, &j); greatNum();// function call return 0; } void greatNum(int x, int y)// function definition { if(i > j) { printf("The greater number is: %d", x); } else{ printf("The greater number is: %d", y); } }

Function with arguments and a return value

เคฏเคน เคธเคฌเคธे เค…เคš्เค›ा เคช्เคฐเค•ाเคฐ เคนै, เค•्เคฏोंเค•ि เคฏเคน function เค•ो เค‡เคจเคชुเคŸ เค”เคฐ เค†เค‰เคŸเคชुเคŸ เคธे เคชूเคฐी เคคเคฐเคน เคธे เคธ्เคตเคคंเคค्เคฐ เคฌเคจाเคคा เคนै, เค”เคฐ function body เค•े เค…ंเคฆเคฐ เค•ेเคตเคฒ เคคเคฐ्เค• เค•ो define เค•िเคฏा เค—เคฏा เคนै।

    
#include <stdio.h> int greatNum(int a, int b);// function declaration int main() { int i, j, result; printf("Enter 2 numbers that you want to compare.."); scanf("%d%d", &i, &j); result =greatNum(i, j);// function call printf("The greater number is: %d", result); return 0; } int greatNum(int x, int y)// function definition { if(i > j) { return x; } else{ return y; } }

Nesting of Functions

C language nesting of functions เค•ी เค…เคจुเคฎเคคि เคฆेเคคी เคนै เคฏाเคจी เค•िเคธी เค…เคจ्เคฏ function body เค•े เค…ंเคฆเคฐ เคเค• function เค•ा เค‰เคชเคฏोเค— / เค•ॉเคฒ เค•เคฐเคจे เค•े เคฒिเค। เคจेเคธ्เคŸेเคก เคซ़ंเค•्เคถंเคธ เค•ा เค‰เคชเคฏोเค— เค•เคฐเคคे เคธเคฎเคฏ เคนเคฎें เคธाเคตเคงाเคจ เคฐเคนเคจा เคšाเคนिเค, เค•्เคฏोंเค•ि เค‡เคธเคธे infinite nesting เคนो เคธเค•เคคी เคนै।

	
	
function1() { // function1 body here function2(); }

เคฏเคฆि function2 () เค•े เค…ंเคฆเคฐ function1 () เค•े เคฒिเค เคญी เค•ॉเคฒ เคนै, เคคो, เค‰เคธ เคธ्เคฅिเคคि เคฎें, เคฏเคน infinite nesting เคนोเค—ा। เคตे เคเค• เคฆूเคธเคฐे เค•ो เคฌुเคฒाเคคे เคฐเคนेंเค—े เค”เคฐ เค•ाเคฐ्เคฏเค•्เคฐเคฎ never terminate เคจเคนीं เคนोเค—ा।


เค†เคชเค•ो เค†เคฐ्เคŸिเค•เคฒ เค•ैเคธा เคฒเค—ा? เค…เคชเคจी เคฐाเคฏ เค…เคตเคถ्เคฏ เคฆें
Please don't Add spam links,
if you want backlinks from my blog contact me on rakeshmgs.in@gmail.com