Header Ads

ad728
  • New Updates

    Function Without Argument But Return Value


    Function Without Argument But Return Value

    इस प्रकार के Function में हम Calling Function से कोई मान , User Defined Function में प्रदान नहीं करते हैं, लेकिन Calling Function को मान Return किया जाता है | इस तरह के Function व्यवहारिक तौर पर बहुत ही कम प्रयोग में आते हैं |

    Example

      Factorial ज्ञात करने का प्रोग्राम Function के प्रयोग से बनाइये |

     

    Program

    
    #include<stdio.h>
    main()
    {
    	int a,b;
    	
    	printf("Enter the factorial value :");
    	scanf("%d",&a);
    	b=fact(a);
    	printf("fact= %d",b);
    	getch();
    }
    fact(int x)
    {
    	int i, sum=1;
    	for(i=1; i<=x; i++)
    	sum *=i;
    	return(sum);
    }
    
    
    
    

    No comments

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728