Skip to main content

Posts

Showing posts from 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...

WAP to read the two matrices and multiply the two matrices in C

WAP to read the two matrices and multiply the two matrices             #include<stdio.h>             #include<conio.h>             void main( )             {                         int x[50][50],y[50][50],z[50][50],i,j,k,m,n,p,q;                         clrscr();                         /*read the first matrix*/                  ...

Wap to read the two arrays and find the sum in C

Wap to read the two arrays and find the sum in "C"             #include<stdio.h>             #include<conio.h>             void main( )             {                                  int x[50][50],y[50][50],z[50][50],i,j,m,n;                         clrscr();                         /*read the first matrix*/            ...

Write a 'c program to read the matrix and find its transpose.

Write  program to read the matrix and find its transpose. #include<stdio.h> #include<conio.h> void main() { int x[50][50],y[50][50],i,j,m,n; clrscr(); /*read the matrix */ printf("\nEnter the value of  m and n :"); scanf("%d %d",&m,&n); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("\nEnter the element :"); scanf("%d",&x[i][j]); } } /*display the matrix*/ clrscr(); printf("\nOriginal Matrix is : \n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%d\t",x[i][j]); } printf("\n"); } /*find the transpose */ for(i=0;i<m;i++) { for(j=0;j<n;j++) { y[j][i]=x[i][j]; } } /*print the transpose */ printf("\n\n Transpose   : \n"); for(i=0;i<n;i++) { for(j=0;j<m;j...

Write a 'c' program to read and display the 2-d array

 R ead and display the 2-d array #include<stdio.h> #include<conio.h> void main() { int x[50][50],i,j,m,n; clrscr(); /*read the matrix */ printf("\nEnter the value of  m and n :"); scanf("%d %d",&m,&n); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("\nEnter the element :"); scanf("%d",&x[i][j]); } } /*display the matrix*/ for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%d\t",x[i][j]); } printf("\n"); } getch(); } 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 onlin...

2-D array Definition and Syntax

Double - Dimension Array 2-D ARRAY  In the case of the double dimension arrays or 2d arrays , we have the concept of arranging the elements in the tabular form, i.e. , in rows and columns. The rows are horizontal and the columns are vertical. The general form of defining the 2d array is , datatype arrayname[nos of rows][nos of columns]; e.g. int x[5][3]; This statement will declare the 2-d array containing the 5 rows and 3 columns, and the array will be declared with the name x. 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...

WAP to read two arrays and find the insertion

WAP to read two arrays and find the insertion in "C" Array 1 : 5,10,15,20,25,30 Array 2 : 10,20,45,60,70 Array 3 : 10,20 #include<stdio.h> #include<conio.h> void main() { int x[50],y[50],z[50],i,j,k,m,n; clrscr(); /*read the array */ printf("\nEnter the value of m:"); scanf("%d",&m); for(i=0;i<m;i++) { printf("\nEnter the element :"); scanf("%d",&x[i]); } /*read the second array */  printf("\nEnter the value of n:"); scanf("%d",&n); for(j=0;j<n;j++) { printf("\nEnter the element :"); scanf("%d",&y[j]); } /*find the intersaction*/ k=0; for(i=0;i<m;i++) { for(j=0;j<n;j++) { if(x[i]==y[j]) { z[k]=x[i]; k++; } } } /* display the insertion of two arrays*/ for(i=0;i<k;i++) { pr...