Skip to main content

Posts

Showing posts from March, 2019

Write a 'C' function to calculate the x ^ y.

'C' function to calculate the x ^ y. x=5 y=3 x^ y=5^3=5*5*5=125 (i) When the functin returns the value  (ii) When the function doesnot returns the value . #include<stdio.h> #include<conio.h> /*function prototype*/ int power(int,int); void main() { int x,y,result; clrscr(); printf("\nEnter the value of  x and y :"); scanf("%d %d",&x,&y); result=power(x,y); /*function call*/ printf("\nResult = %d",result); getch(); } /*function defintion*/ int power(int x,int y) { int i,result; result=1; for(i=1;i<=y;i++) result=result*x; return result; } Join us on Facebook  :-  Practice program -JAVA c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c com...

Write a 'c' program using function to calculate the value of c(ncr)

Function to calculate the value of c(ncr) in C c =     n!                    ----------                     r!*(n-r)! #include<stdio.h> #include<conio.h> /*function prototype*/ int factorial(int); void main( ) { int n,r,c,factn,factr,factnr; clrscr(); printf("\nEnter the value of n and r:"); scanf("%d%d",&n,&r); /*calculate the factorial of n */ factn=factorial(n); /*calculate the factorial of r */ factr=factorial(r); /* calculate the factorail of n-r*/ factnr=factorial(n-r); /*calculate the value of c */  c=factn/(factr*factnr); printf("\nc=%d",c); getch(); } /*function definition */ int factorial(int num) { int fact=1,i; for(i=1;i<=num;i++) fact=fact*i; return fact; } Join us on Facebook:  Click Here c pr...

Write a 'c' program to calculate the factorial of the number using Function

Calculate the factorial of the number using Function in C (i) When the function  returns the value #include<stdio.h> #include<conio.h> /*function prototype*/ int factorial(int); void main( ) { int num,fact; clrscr(); printf("\nEnter the number :"); scanf("%d",&num); fact=factorial(num); /*function call*/ printf("\nFactorial = %d",fact); getch(); } /*function defintion */ int factorial(int num) { int i,fact; fact=1; for(i=1;i<=num;i++) fact=fact*i; return fact; } (ii) When the function does not return the value  #include<stdio.h> #include<conio.h> /*function prototype */ void factorial(int); void main() { int num; clrscr( ); prindtf("\nEnter the number :"); scanf("%d",&num); factorial(num); /* function call*/ getch(); } /* function definition */ void factorial...

WAP When the function does not return the value in C

The function does not return the value in C #include<stdio.h> #include<conio.h> /*function prototype*/ void sum(int,int); void main( )  { int a,b; clrscr(); printf("\nEnter the value of a and b:"); scanf("%d %d",&a,&b); sum(a,b);      /*function call*/ getch(); } /*function definition */ void sum(int a,int b) { int c; c=a+b; printf("\nSum = %d",c); } c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler online c++ compiler,gdb compiler,c programming practice questions pdf,c programming practice online,c programming coding questions and answers pdf,100 c programming exercises pdf c programming exercises with so...

Write a "C" function to add two numbers.

"C" function to add two numbers #include<stdio.h> #include<conio.h> /*function prototype*/  int sum(int,int); void main( )  { int a,b,c; clrscr(); printf("\nEnter the value of a and b:"); scanf("%d %d",&a,&b); c=sum(a,b);/*function call*/ printf("\nSum = %d",c); getch(); } /*function definition */ int sum(int i,int j) { int k; k=i+j; return k; } c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler online c++ compiler,gdb compiler,c programming practice questions pdf,c programming practice online,c programming coding questions and answers pdf,100 c programming exercises pdf c programming exercises with sol...

User-defined functions types with example

User-defined functions Function Prototype Function call Function definition User-defined functions : These functions are defined by the user for there own prupose. These functions contains the following components :  (a) Function Prototype. (b) Function call (c) Function definition  (a) Function Prototype : The function prototype is used to specify the layout of the function. The function prototype specifies the following information :  (i) The function name  (ii) The number of arguments the function requires (iii) The type of  arguments  (iv) The returntype. The general form is , return type function name(argument list); Example 1 :  int sum(int ,int); It specifies that there will be a function with the name  sum( ) and this function will take two arguments and both are of type integers and the sum() will also return the integer type value. float average(f...

What is Functions and Define its types

What is Functions Function is the block of code which is used to perform a particular operation. There are two type of the functions :  (i)  Pre-defined functions  (ii) User -defined functions . Monolithic Programming : In this case , we write the entire login in the single program/ The disadvantages of the monolithic programming are, (a) Difficult to understand. (b) Difficult to modify (c) Difficult of debug. [ Bug means computer program error and debugging is the process of locating and removing the computer    program error .]   Modular Programming : In the case of the modular programming , we divide the entire complex program into the simple sub-programs or modules.These modules are also known as functions. Advantages of the modular programming :  (a) Easy to understand  (b) Easy to debug (c) Easy to modify  (d) Resuability of code. (i) Pre-defined Funct...