BCA Bachelor of computer application.
3.25K 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
Program to calculate the determinant of 3ร—3 matrix.

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

void main()
{
int a[3][3], i, j;
long determinant;
clrscr();

printf("Enter the 9 elements of matrix :\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
scanf("%d", &a[i][j]);
}
}

printf("\nThe matrix is :\n");
for (i = 0; i < 3; i++)
{
printf("\n");
for (j = 0; j < 3; j++)
{
printf("%d\t", a[i][j]);
}
}

determinant = a[0][0] * ((a[1][1] * a[2][2]) - (a[2][1] * a[1][2]))
- a[0][1] * (a[1][0] * a[2][2] - a[2][0] * a[1][2])
+ a[0][2] * (a[1][0] * a[2][1] - a[2][0] * a[1][1]);

printf("\nDeterminant of 3X3 matrix : %ld", determinant);

getch();
}
@bca_official
Program to find Largest and Smallest number in array.

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

void main()
{
int a[50], size, i, largest, smallest;
clrscr();

printf("Enter the size of the array : ");
scanf("%d", &size);

for (i = 0; i < size; i++)
{
printf("Enter element %d in to the array : ", i);
scanf("%d", &a[i]);
}

largest = a[0];
for (i = 1; i < size; i++)
{
if (largest < a[i])
{
largest = a[i];
}
}
printf("Largest element : %d", largest);

smallest = a[0];
for (i = 1; i < size; i++)
{
if (smallest > a[i])
{
smallest = a[i];
}
}
printf("\nSmallest element : %d", smallest);
getch();
}
Program to check perfect number.

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

void main()
{
int n, i = 1, sum = 0;
clrscr();
printf("Enter a number : ");
scanf("%d", &n);

/*The first perfect number is 6, because 1, 2, and 3 are its proper positive divisors, and 1 + 2 + 3 = 6.*/

while (i < n)
{
if (n % i == 0)
{
sum = sum + i;
}
i++;
}

if (sum == n)
{
printf("\n%d is a perfect number.", i);
}
else
{
printf("\n%d is not a perfect number.", i);
}
getch();
}
Program to take a number from user and check whether it is Armstrong number or not.

#include<stdio.h>
#include<conio.h>
void main()
{
int i=2, temp, rem, sum=0, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
temp = n;

while(n>0)
{
rem = n%10;
sum = sum+(rem*rem*rem);
n = n/10;
}

if(temp==sum)
printf("Entered number is an Armstrong Number");
else
printf("Entered number is not an Armstrong Number");
getch();
}
Binary Search

#include<stdio.h>

int main()
{

int arr[20],n,mid,ele,i;

printf("\nHow many elements:");

scanf("%d",&n);
printf("%d",n);
printf("\nEnter the elememts in sorted manner:");

for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}

for(i=0;i<n;i++)
{
printf("%d",arr[i]);
printf(" ");
}
printf("\nEnter the element to be searched for:");
scanf("%d",&ele);
printf("%d",ele);
mid=n/2;
if(ele<=arr[n-1])
{
if(arr[mid]>ele)
{
for(i=0;i<mid;i++)
{
if(arr[i]==ele)
{
printf("\n\nPosition=%d",i);
break;
}
}
}
else if(arr[mid]<ele)
{
for(i=mid;i<n;i++)
{
if(arr[i]==ele)
{
printf("\n\nPosition=%d",i);
break;
}

}
}
else

printf("\n\nPosition=%d",mid);

}
else
printf("\nNo such element exists");
return 0;
}
# program by @Dreamy_prince
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
1.New Driver's License

You have to get a new driver's license and you show up at the office at the same time as 4 other people. The office says that they will see everyone in alphabetical order and it takes 20 minutes for them to process each new license. All of the agents are available now, and they can each see one customer at a time. How long will it take for you to walk out of the office with your new license?

Task
Given everyone's name that showed up at the same time, determine how long it will take to get your new license.

Input Format
Your input will be a string of your name, then an integer of the number of available agents, and lastly a string of the other four names separated by spaces.

Output Format
You will output an integer of the number of minutes that it will take to get your license.

Sample Input
'Eric'
2
'Adam Caroline Rebecca Frank'

Sample Output
40

Explanation
It will take 40 minutes to get your license because you are in the second group of two to be seen by one of the two available agents.

Solution:
#include <stdio.h>
#include<string.h>
int main() {
char str[30],ch[10];
int num,n,i,a=0;
scanf("%s\n",ch);
scanf("%d\n",&n);
gets(str);

if(ch[0]>str[0])
a++;
for(i=0;i<strlen(str);i++)
{ if(str[i]==' ')
if(ch[0]>str[i+1])
a++;
}
num=a/n+1;
printf("%d",num*20);

return 0;
}

๐Ÿ‘‡Never forget to join this channel ๐Ÿ‘‡
http://t.me/BCA_official
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 ๐Ÿ‘†
Binary search using recursion
#include<stdio.h>

int binary(int arr[], int n, int search, int l, int u);

int main()
{
int arr[10], i, n, search, c, l, u;

printf("Enter the size of an array : ");
scanf("%d", &n);

for (i = 0; i < n; i++)
{
printf("Enter the element %d : ", i+1);
scanf("%d", &arr[i]);
}

printf("Enter the number to be search: ");
scanf("%d", &search);

l = 0, u = n - 1;
c = binary(arr, n, search, l, u);

if (c == 0)
printf("Number not found.");
else
printf("Number found.");

return 0;
}

int binary(int arr[], int n, int search, int l, int u)
{

int mid, c = 0;

if (l <= u)
{
mid = (l + u) / 2;
if (search == arr[mid])
{
c = 1;
}
else if (search < arr[mid])
{
return binary(arr, n, search, l, mid - 1);
}
else
return binary(arr, n, search, mid + 1, u);
}
else
return c;
}
@bca_official
DIGITAL CLOCK PROGRAM USING CLASS IN C++

#include<iostream>
#include<ctime>
#include<cstdlib>

using namespace std;

int main()
{
int sec_prev=0;
while(1)
{
int seconds, minutes, hours;
string str;

//storing total seconds
time_t total_seconds=time(0);

//getting values of seconds, minutes and hours
struct tm* ct=localtime(&total_seconds);

seconds=ct->tm_sec;
minutes=ct->tm_min;
hours=ct->tm_hour;

//converting it into 12 hour format
if(hours>=12)
str="PM";
else
str="AM";
hours=hours>12?hours-12:hours;


//printing the result
if(seconds==sec_prev+1 || (sec_prev==59 && seconds==0))
{
system("CLS");
cout<< (hours<10?"0":"") << hours <<":" << (minutes<10?"0":"") << minutes << ":" << (seconds<10?"0":"") << seconds << " " << str <<endl;
}

sec_prev=seconds;

}

return 0;
}

Click Here For More.. @bca_official
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib.h>
void women();
void man();
void rose(int);
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
man();
getch();
closegraph();
}
void man()
{
int i;
for(i=1;i<=230;i+=2)
{
if(i%3==0)
{
women();
//man
circle(100+i,300,15);
line(100+i,315,100+i,360);
//leg
line(100+i,360,90+i,400);
line(100+i,360,110+i,400);
//hand 1
line(100+i,330,90+i,360);
//
line(100+i,330,115+i,340);
line(115+i,340,130+i,330);
rose(i);
setcolor(WHITE);
}

else
{
women();
//MAN
circle(100+i,300,15);
line(100+i,315,100+i,360);
//leg
line(100+i,360,95+i,400);
line(100+i,360,105+i,400);
//hand 1
line(100+i,330,101+i,360);
//
line(100+i,330,115+i,340);
line(115+i,340,130+i,330);
rose(i);
setcolor(WHITE);
}
delay(100);
cleardevice();
}
}
void women()
{
line(1,400,800,400);
//man
circle(400,300,15);
//body
line(400,315,380,365);
line(400,315,420,365);

line(380,365,420,365);
//legs
line(390,365,390,400);
line(410,365,410,400);
//hand
line(400,330,380,350);
}
void rose(int i)
{
setcolor(GREEN);
line(130+i,323,130+i,335);
setcolor(RED);
circle(130+i,321,2);
setfillstyle(1,RED);
floodfill(130+i,321,RED);
}


Code
๐Ÿ‘12โค1
// C++ program to calculate total, average and
// percentage marks of all subjects

#include <iostream>
using namespace std;

int main(){
int subjects, i;
float marks, total=0.0f, averageMarks, percentage;

// Input number of subjects

cout << "Enter number of subjects\n";
cin >> subjects;

// Take marks of subjects as input
cout << "Enter marks of subjects\n";

for(i = 0; i < subjects; i++){
cin >> marks;
total += marks;
}

// Calculate Average
averageMarks = total / subjects;

// Each subject is of 100 Marks
percentage = (total/(subjects * 100)) * 100;

cout << "Total Marks = " << total;
cout << "\nAverage Marks = " << averageMarks;
cout << "\nPercentage = " << percentage;

return 0;
}
๐Ÿ‘8โค2๐Ÿ”ฅ2