Program of Array
Program of Array
Program of Array
#include <stdio.h>
main()
int i, j, a, n, number[30];
scanf("%d", &n);
scanf("%d", &number[i]);
a = number[i];
number[i] = number[j];
number[j] = a;
}
printf("%d\n", number[i]);
Searching :
#include <stdio.h>
main()
{ int num;
scanf("%d", &num);
int array[num];
scanf("%d", &array[i]);
scanf("%d", &keynum);
if (keynum == array[i] )
found = 1;
break;
if (found == 1)
else
}
Matrix multiplication :
#include<stdio.h>
main()
int r1,r2,c1,c2;
scanf("%d",&r1);
scanf("%d",&c1);
scanf("%d",&r2);
scanf("%d",&c2);
if(c1!=r2)
else
{
int m1[r1][c1],m2[r2][c2];
for(int i=0;i<r1;i++)
for(int j=0;j<c1;j++)
scanf("%d",&m1[i][j]);
for(int i=0;i<r2;i++)
for(int j=0;j<c2;j++)
scanf("%d",&m2[i][j]);
int mul[r1][c2];
for(int i=0;i<r1;i++)
{
for(int j=0;j<c2;j++)
mul[i][j]=0;
for(int k=0;k<c1;k++)
mul[i][j]+=m1[i][k]*m2[k][j];
printf("Multiplied matrix\n");
for(int i=0;i<r1;i++)
for(int j=0;j<c2;j++)
printf("%d\t",mul[i][j]);
printf("\n");
}
}