Showing posts with label C Projects. Show all posts
Showing posts with label C Projects. Show all posts

C Program Code for Factorial of a Number in a Given Range

Program Code:

#include<stdio.h>
int main()
{
int fact =1 ,n , i ,j;
printf("Enter Range A :  ");
scanf("%d",&n);
printf("\n\n");
printf("A\t\tFactorial A\n\n");
    for(i =1;i<n;i++)
{
for(j=1;j<=i;j++)
{
fact = fact * j;
}
printf("%d",i,"\t\t",fact);
printf("\n");
fact = 1;
}
return 0;
}

Output:

.exe file

C Program Code for Printing Diamond Shape

Program Code:


#include<stdio.h>
int main()
{
int a=10 ,b =9 ;
int i,j,k,x,y,z;
for(i =1;i<=10;i++)
{
for(j =1;j<=a;j++)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("*");
printf(" ");
}
a--;
printf("\n");
}
for(x =1;x<=9;x++)
{
for(z = 1;z<=x;z++)
{
printf(" ");
}
for(y=1;y<=b;y++)
{
printf(" ");
printf("*");
}
printf("\n");
b--;
}
return 0;
}

Output:

.exe file

C Program Code for Swapping of numbers using Pointers

Program code:

#include<stdio.h>
int main()
{
int x  , y , z , *a , *b , *c  ;
printf("Enter value of x : ");
scanf("%d",&x);
printf("Enter value of y : ");
scanf("%d",&y);
printf("Before swapping x :  %d",x);
printf("\nBefore swapping y :  %d",y);
a = &x;
    b = &y;
c = &z;
*c = *a;
*a = *b;
*b = *c;
printf("\nAfter swapping x :  %d",x);
printf("\nAfter swapping y :  %d",y);
return 0;
}

Output:

.exe file

C Program for Printing English Alphabets in Triangle Shape

Program Code:

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
for(i=0;i<26;i++)
{
for(j=0;j<=i;j++)
printf("%3c",j+65);
printf("\n");
}
getch();
}

Output:

.exe file

C Program For separating Digits from Number

Program Code:

#include<stdio.h>
int main()
{
int number ,a[5] ,i , temp , j;
printf("Enter any 5 digit number :  ");
scanf("%d",&number);

for(i =0;i<5;i++)
{
temp = number % 10;
a[i] = temp ;
number = number / 10 ;
}

printf("Digits are :  %d , %d , %d , %d , %d \n" ,a[4] ,a[3] ,a[2],a[1],a[0]);

return 0;
}

Output:

.exe file

C Program Code for Printing Heart Shape

Program Code:

#include<stdio.h>
int main()
{
int i,j,k,l,m,n,o,p,q,r,s,t;
printf("\n\n\n\n\n");

for(i=0;i<15;i++)
printf(" ");
printf("*         *\n");

for(j=0;j<13;j++)
printf(" ");
printf("*   *     *   *\n");

for(k=0;k<11;k++)
printf(" ");
printf("*      *   *      *\n");

for(l=0;l<11;l++)
printf(" ");
printf("*       * *       *\n");

for(m=0;m<11;m++)
printf(" ");
printf("*        *        *\n");

for(n=0;n<11;n++)
printf(" ");
printf("*                 *\n");

for(o=0;o<12;o++)
printf(" ");
printf("*               *\n");

for(p=0;p<13;p++)
printf(" ");
printf("*             *\n");

for(q=0;q<14;q++)
printf(" ");
printf("*           *\n");

for(r=0;r<15;r++)
printf(" ");
printf("*         *\n");

for(s=0;s<17;s++)
printf(" ");
printf("*     *\n");

for(t=0;t<20;t++)
printf(" ");
printf("**\n");
return 0;
}

Output:

.exe file

C Program for printing Right Angled Triangle Shape

Program Code:

#include<stdio.h>
int main()
{
int i, j ,l;
for(i=1;i<=10;i++)
{
    printf("-");

for(j=1;j<i;j++)
{
printf("  ");
}
printf("*");
printf("\n");
}
for(l=0;l<20;l++)
printf("+");
printf("\n");
}

Output:

.exe file

To print Stars in Right Angled Triangle Shape Using C Programming Langugae

How to print stars in  right angled triangle shape using C programming ?
C program Code for printing stars in right angled triangle shape ?

Program Code:

#include<stdio.h>
int main()
{
int i, j;
for(i=1;i<=10;i++)
{
for(j=0;j<i;j++)
printf("*");
printf("\n");
}
}

Output:

.exe file


C Program for Printing Stars

How to print stars in square shaped ?
Print stars using C programming language ?

Program Code;

#include<stdio.h>
int main()
{
int i, j;
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
printf("*");
printf("\n");
}
}

Output:

.exe file

C Program Code for Transpose of Matrix

Question Types:

Find Transpose of matrix using c programming language ?
How to print transpose of matrix entered by the user using c programming language ?

Program Code:

#include<stdio.h>
// visit informativei.blogspot.com 
int main()
{
int a[3][3] ,b[3][3] , i ,j; // two arrays or matrices and two variables
// code for getting elements from user
printf("Enter 3*3 Matrix A:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
// for displaying matrix A
printf("\nMatrix A : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d  ",a[i][j]);
}
printf("\n");
}
// code for converting into its transpose
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
b[j][i]=a[i][j]; // convert rows of matrix a into columns of matrix b
}
}
// code for displaying transpose matrix A
printf("\nTranspose of Matrix B : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d ",b[i][j]);
}
printf("\n");
}
return 0;
}

// visit informativei.blogspot.com 

Output:

.exe file

C Program code For Multiplication of Matrices

Question Types:

Program Code for multiplication of matrices of any order using c programming language ?
Print multiplication of matrices using c language and also show if multiplication is not possible ?

Program Code:

#include<stdio.h>
int main()
{
int a[][] , b[][] , c[][];
int i, j , k ;
int n, m, p , q;
printf("Enter no.of rows and coloumns of Matrix A :\n ");
scanf("%d %d",&n,&m);
printf("\nEnter no.of rows and coloumns of Matrix B :\n ");
scanf("%d %d",&p,&q);
if(m==p)
{
// Matrix a ==> Getting elements from user
    printf("\n\nEnter elements for matrix A :\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++){
scanf("\t%d",&a[i][j]);
}
}

// Matrix b ==> Getting elements from user
    printf("\nEnter elements for matrix B :\n");
for(i=0;i<p;i++)
{
for(j=0;j<q;j++){
scanf("\t%d",&b[i][j]);
}
}
// Matrix a ==> displaying code
    printf("\n\nMatrix A: \n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++){
printf("\t %d\t",a[i][j]);
}
printf("\n");
}

// Matrix b ==> displaying code
    printf("\n\nMatrix B: \n");
for(i=0;i<p;i++)
{
for(j=0;j<q;j++){
printf("\t %d\t",b[i][j]);
}
printf("\n");
}
// Matix c = Matrix a * Matrix b
   for(i=0;i<m;i++)
   {
       for(j=0;j<p;j++)
      {
             c[i][j]=0;
      for(k = 0; k<m;k++)
           {
             c[i][j] =c[i][j] +( a[i][k] * b[k][j] );
   
           }     
       
    }
   
   }
   
// Matrix C ==> Displaying code
    printf("\n\nMatrix C = Matirx A * Matrix B :\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++){
printf("\t %d\t",c[i][j]);
}
printf("\n");
}
}
else
printf("Multiplication is not possible ,,,,,");
return 0;
}

Output:

.exe file 

C Program Code for Subtraction of Matrices

Question Types:

Print subtraction of matrices using c programming language ? 
How to find subtraction of matrices using C programming language ?

Program Code:

#include<stdio.h>
int main()
{
int a[2][2] , b[2][2] , c[2][2];
int i, j , k ,l;
// Matrix a ==> Getting elements from user
    printf("Enter elements for matrix A :\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++){
scanf("\t%d",&a[i][j]);
}
}

// Matrix b ==> Getting elements from user
    printf("\nEnter elements for matrix B :\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++){
scanf("\t%d",&b[i][j]);
}
}
// Matrix a ==> displaying code
    printf("\n\nMatrix A: \n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++){
printf("\t %d\t",a[i][j]);
}
printf("\n");
}

// Matrix b ==> displaying code
    printf("\n\nMatrix B: \n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++){
printf("\t %d\t",b[i][j]);
}
printf("\n");
}
// Matix c = Matrix a - Matrix b
   for(i=0;i<2;i++)
   {
    for(j=0;j<2;j++)
    {
    c[i][j] = a[i][j] - b[i][j];
    }
   }
   
// Matrix C ==> Displaying code
    printf("\n\nMatrix C = Matirx A - Matrix B :\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++){
printf("\t %d\t",c[i][j]);
}
printf("\n");
}
return 0;
}

Output:

output .exe file

C Program Code for Division of Numbers

Question Types:

C program code for division of numbers ?
Display division of numbers using c programming language ?

Program Code:

Division of Numbers 

Output:

.exe file


C Program Code for Multiplication of Numbers

Question Types:

C program code for multiplication of numbers ?
Display multiplication of numbers using C programming language ?

Program Code:

Multiplication of Numbers

Output:

.exe file

C Program Code for Subtraction of Numbers

Question Types:

C program code for subtraction of numbers ?
Display subtraction of numbers using c programming language ?

Program Code:

Subtraction of Numbers

 Output:

.exe file

Program Code for Addition of Two Numbers using C programming Language

Question Types:

Write C program code for addition of numbers ?
Display addition of two number using C programming Language ?

Program Code:

Addition of Numbers 

Output:

Output .exe file

C Program Code of Area of Rectangle

Question types:

C program code for area of rectangle ?
Print area of rectangle using C programming language ?

Program Code:

Area of rectangle c code

Output:

.exe file

C program code for Area of Square

Question types:

C program code for area of square ?
Print area of square using C programming language ?

Program Code:

area of square c code

Output:

.exe file

C Program Code for Area of Ellipse

Question Types:

C program code for area of Ellipse ?
How to find area of of ellipse using c programming language ?

Program Code:

Area of Ellipse C code

Output:

.exe file

C Program Code for Area of Trapezium

Question Types:

C program code for area of trapezium ?
How to find area of trapezium using C language ?

Program Code:

area of trapezium c code

Output:

.exe file

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.