BCA Bachelor of computer application.
3.24K subscribers
323 photos
95 videos
161 files
425 links
Access study materials, free books, discussions, queries, previous exam papers, and mock tests for BCA, MCA, and other competitive exams. Additionally, resources related to hacking are also available. Join our group https://t.me/bca_official for more!
Download Telegram
122. Multiplication of two Matrices

#include<stdio.h>
int main()
{

int a[5][5], b[5][5], c[5][5], m, n, p, q, i, j, k;

printf( "Enter rows and columns of first matrix: ");
scanf("%d%d",&m,&n);

printf("Enter rows and columns of second matrix: ");
scanf("%d%d",&p ,&q);

if (n == p)
{
printf("\nEnter first matrix:\n");
for(i = 0; i < m; ++i)
{for (j = 0; j < n; ++j)
scanf("%d",&a[i][j]);
}

printf("\nEnter second matrix:\n");
for (i = 0; i < p; ++i)
for (j = 0; j < q; ++j)
scanf("%d",&b[i][j]);

printf("\nThe new matrix is:\n");

for (i = 0; i < m; ++i)
{
for (j = 0; j < q; ++j)
{
c[i][j] = 0;
for (k = 0; k < n; ++k)
c[i][j] = c[i][j] + (a[i][k] * b[k][j]);
printf("%d\t",c[i][j]);
}
printf( "\n");
}
}
else
printf("\n Matrix can't be multiplied");

return 0;
}
#Program_by : @Dreamy_prince
TRUNCATABLE PRIMES

A prime number without zero digits is called
right truncatable if all numbers obtained by
successively removing the rightmost digits
are prime

Example:

239 is right truncatable

239 => 23 => 2   all of them primes


The first few are 2, 3, 5, 7, 23, 29, 31, 37, 53, 59, 71, 73, 79, 233, 239, 293, 311, 313, 317, 373, 379, 593, 599

A prime number without zero digits is called
left truncatable when removing leftmost
digits the obtained numbers are all primes

Example:

167 is left truncatable

167 => 67 => 7

The first few are 2, 3, 5, 7, 13, 17, 23, 37, 43, 47, 53, 67, 73, 83, 97, 113, 137, 167, 173


Challenge:

Search right and left truncatable primes

between the first 5000 primes

Solution :

#include<stdio.h>

int flag = 0;
int zero_check( int i){
int flag = 1;
if((( i / 100) % 10 != 0 && ( i % 100) / 10 != 0 && ( i % 100) % 10 != 0) || i < 100) flag = 0;
return flag;
}
int even_check( int i){
for(int j = 2 ; j <= i ; j++){
if( i % j == 0 && j != i) return 1;
else if( i % j == 0 && j == i) return 0;
}
}
int truncatable_check( int i,int flag){
if(flag==0){
if(even_check( i % 1000) == 0 && even_check( i % 100) == 0 && even_check(( i % 1000) % 10) == 0) return 0;
}
else if(flag==1) if(((even_check(i/1000)==0) || (i/1000==0)) && ((even_check(i/100)==0) || (i / 100 == 0)) && ((even_check (i/10)==0) || (i/10==0))) return 0;
}
int main(){
int limit = 5000 , i;
(flag==0)?printf("LEFT TRUNCATABLE:\n\n"):printf("\n\nRIGHT TRUNCATABLE:\n\n");
for(i = 1; i <= limit; i++){
if(even_check(i) == 0){
if(zero_check(i) == 0){
if( flag == 0){
if ( truncatable_check( i , flag) == 0) printf("%d ",i);
}
else if( flag == 1) if(truncatable_check( i, flag) == 0) printf("%d ",i);
}
}
}
if(flag!=1){
flag=1;
main();
}
return 0;
}
#Program_by: @dreamy_prince
@BCA_official
Our Channel 👆