Write a Program to perform array multiplication( C programming).

Program:

#include<conio.h>
#include<stdio.h>

void main()
{
    int a[25][25],b[25][25],c[25][25],i,j,m,n,o,k;
    clrscr();
    printf("\nEnter row & column in A:\n");
        scanf("%d\n%d",&m,&n);
    printf("\nEnter the column value in B:\n");
        scanf("%d",&o);
    printf("\nEnter %d*%d value of A\n",m,n);
    for(i=0; i< m; i++)
        for(j=0; j< n; j++)
            scanf("%d",&a[i][j]);
    printf("\nEnter %d*%d value of B\n",n,o);
    for(i=0; i< n; i++)
        for(j=0; j< o; j++)
            scanf("%d",&b[i][j]);
    printf("\nA values:\n");
    for(i=0; i< m; i++)
    {
        for(j=0; j< n; j++)
            printf("%d\t",a[i][j]);
        printf("\n");
    }
    printf("\nB values:\n");
    for(i=0; i< n; i++)
    {
        for(j=0; j< o; j++)
            printf("%d\t",b[i][j]);
        printf("\n");
    }

    for(i=0; i< m; i++)
        for(k=0; k< o; k++)
        {
            c[i][k]=0;
            for(j=0; j< n; j++)
            {
            c[i][k]=c[i][k]+a[i][j]*b[j][k];
            }
        }
    printf("\nC values:\n");
    for(i=0; i< m; i++)
    {
        for(j=0; j< o; j++)
            printf("%d\t",c[i][j]);
        printf("\n");
    }
get
ch();
}

Sample Output:


Write a Program to print the Pascal Triangle. (or) to print the Following format





1






1
1




1
2
1


1
3
3
1
1
4
6
4
1



Program:

#include<stdio.h>
#include<conio.h>

void main()
{
    int a,b,i,j,d[30],t[30];
    clrscr();
    printf("Enter the max limit:");
        scanf("%d",&a);
    b=a;
    for(i=0;i< a;i++)
    {

//Initialisation..
        t[0]=1; t[i]=1;
d[0]=1;

//Spacing..
        for(j=0;j< b-1;j++)
            printf(" ");
        b--;

//Calculation..
        for(j=1;j<=i;j++)
        {
        d[j]=t[j-1]+t[j];
        }
        d[i]=1;

//Printing..
        for(j=0;j<=i;j++)
        {
            printf("%d ",d[j]);
            t[j]=d[j]; //Restoring temporary Array..
        }

        printf("\n");
    }
getch();
}


Sample Output:



Programs and Solutions