Posts

C program to find power of given number.

Question: Write a Program in C to find out value of given power(X,Y) of number using recursion. Source Code: #include void Pow1(int x,int y) { if(y==0) { printf("1"); } else { printf(x*Pow1(x,(y-1))); } } int main() { int x,y; printf("Enter the value of x and y\n"); scanf("%d \n %d \n",&x,&y); printf("Value is:\n"); Pow1(x,y); return 0; } Output: Enter the value of x and y 2 2 Value is: 4

C program to find roots of Quadratic Equation.

Question: Write a Program in C to find the roots of Quadratic Equation. Source Code: #include #include int main() { int a,b,c,det; double root1,root2; printf("Enter the value of a, b and c from Quadratic Equation\n"); scanf("%f \n %f \n %f \n" ,&a, &b, &c); det=(b*b)-(4*a*c); if(det Output: Enter the value of a, b and c from Quadratic Equation 1 -2 1 Root1=1.00 Root2=1.00

C program to find fibonacci series.|c |languagecopy.blogspot.

Question: Write a Program in C to take input from user and find the fibonacci series of number. Source Code: #include void fib(int num1) { if(num1==0) { printf("0"); } else if(num1==1) { printf("0 , 1"); } else { int term1=0,term2=1; int i,next; for(i=0;i Output: Enter the number to find the fibonacci series 5 fibonacci series: 0,1,1,2,3,

C program to take elements of Matrix 3x3 and find transpose of matrix.|C |languagecopy.blogspot.com|

Question: Write a Program in C to take elements of a matrix[3][3] and find the transpose of matrix. Source Code: #include int main() { int mat[3][3],i,j; printf("Enter the elements of matrix 3X3\n"); for(i=0;i Output: Enter the elements of matrix 3X3 Original Mtrix is: 1 2 3 4 5 6 7 8 9 Transpose of Mtrix is: 1 4 7 2 5 8 3 6 9

C program to find the factorial of number.|Recursion Function|

Question: Write a Program in C to take input from user and find the factorial of a given number. Source Code: #include int fact(int num) { if (num==0 || num==1) { return 1; } else { return (num*fact(num-1)); } } int main() { int num1; printf("Enter Number\n"); scanf("%d",&num1); printf("Factorial of numbers is :%d",fact(num1)); return 0; } Output: Enter Number 5 Factorial of numbers is:120

C program to create a simple Calculator using Function.

Question: Write a Program in C to create a simple calculator to perform addition, subtraction, multiplication division and modulus. Source Code: #include int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } int mul(int a, int b) { return a*b; } int divi(int a, int b) { return (a/b); } int mod(int a, int b) { return a%b; } int main() { int num1,num2,choice; char c; hello: printf("*Calculator*\n"); printf("Enter Choice\n"); printf("1. Addition \n 2. Subtraction \n 3. Multiplication \n 4. Division \n 5. Modulus \n "); scanf("%d",&choice); switch(choice) { case 1: printf("Enter two numbers;\n"); scanf("%d \n %d",&num1,&num2); printf("Addition:%d",add(num1,num2)); break; case 2: printf("Enter two numbers;\n"); scanf("%d \n %d",&num1,...

C program to subtract Matrix1 to Mtrix2.

Question: Write a C program to take elements of two matrix 3 X 3 and do the subtraction and display the result. Source Code: #include int main() { int mat1[3][3],i,j; int mat2[3][3],mat3[3][3]; printf("Enter elements of Matrix 1\n"); for(i=0;i Output: Enter elements of Matrix 1 1 2 3 4 5 6 7 8 9 Enter elements of Matrix 2 1 2 4 5 6 7 8 9 elements of Matrix 1 1 2 3 4 5 6 7 8 9 elements of Matrix 2 1 2 3 4 5 6 7 8 9 Subtraction of two matrix is: 0 0 0 0 0 0 0 0 0